-
Notifications
You must be signed in to change notification settings - Fork 13
107 lines (92 loc) · 3.59 KB
/
build.caddy-cloudflare.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Workflow to build and push a Docker image to Docker Hub, GitHub and Quay Container Registries
name: Build caddy-cloudflare
# Controls when the action will run
on:
workflow_dispatch: # allows to run the workflow manually from the Actions tab
schedule:
- cron: '0 0 1 * *' # runs at 00:00 on the first day of every month
push:
branches: main
paths:
- caddy-cloudflare/Dockerfile
# Environment variables available to all jobs and steps in this workflow
env:
DOCKER_BUILDKIT: 1
DOCKER_NAME: caddy-cloudflare
DOCKER_DESCRIPTION: "Caddy Docker custom build with Cloudflare DNS/IPs modules"
# Jobs to run once the workflow is triggered
jobs:
# Job to get image and repository details
metadata:
name: Get image and repository details
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ steps.metadata.outputs.tags }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Parse Caddy version
id: version
run: echo "version=$(grep -Eo 'caddy:[0-9]+\.[0-9]+\.[0-9]+$' $DOCKER_NAME/Dockerfile | cut -d ':' -f2)" | tee -a $GITHUB_OUTPUT
- name: Generate image metadata with Caddy version
uses: docker/metadata-action@v5
id: metadata
with:
images: |
docker.io/${{ github.actor }}/${{ env.DOCKER_NAME }}
ghcr.io/${{ github.actor }}/${{ env.DOCKER_NAME }}
quay.io/${{ github.actor }}/${{ env.DOCKER_NAME }}
tags: |
type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.version }}
type=semver,pattern={{major}},value=v${{ steps.version.outputs.version }}
labels: |
org.opencontainers.image.title=${{ env.DOCKER_NAME }}
org.opencontainers.image.description=${{ env.DOCKER_DESCRIPTION }}
# Job to build and publish Docker image
build:
name: Build and publish Docker image
runs-on: ubuntu-latest
needs: metadata
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Repository
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Login to Quay Container Registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ github.actor }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build and publish container image
uses: docker/build-push-action@v6
id: build
with:
context: .
file: ./${{ env.DOCKER_NAME }}/Dockerfile
push: true
provenance: false
tags: ${{ needs.metadata.outputs.tags }}
labels: ${{ needs.metadata.outputs.labels }}
platforms: ${{ needs.metadata.outputs.platforms }}