@@ -3,85 +3,84 @@ name: Docker
33# Based on a template from GitHub
44
55on :
6- push :
7- branches : [ "main", "develop", "nightly" ]
8- # Publish semver tags as releases.
9- tags : [ ' v*.*.*' ]
10- pull_request :
11- branches : [ "main", "develop", "nightly" ]
6+ push :
7+ branches : ["main", "develop", "nightly"]
8+ # Publish semver tags as releases.
9+ tags : [" v*.*.*" ]
10+ pull_request :
11+ branches : ["main", "develop", "nightly"]
1212
1313env :
14- # Use docker.io for Docker Hub if empty
15- REGISTRY : ghcr.io
16- # github.repository as <account>/<repo>
17- IMAGE_NAME : ${{ github.repository }}
14+ # Use docker.io for Docker Hub if empty
15+ REGISTRY : ghcr.io
16+ # github.repository as <account>/<repo>
17+ IMAGE_NAME : ${{ github.repository }}
1818
1919jobs :
20- build :
20+ build :
21+ runs-on : ubuntu-latest
22+ permissions :
23+ contents : read
24+ packages : write
25+ # This is used to complete the identity challenge
26+ # with sigstore/fulcio when running outside of PRs.
27+ id-token : write
2128
22- runs-on : ubuntu-latest
23- permissions :
24- contents : read
25- packages : write
26- # This is used to complete the identity challenge
27- # with sigstore/fulcio when running outside of PRs.
28- id-token : write
29+ steps :
30+ - name : Checkout repository
31+ uses : actions/checkout@v6
32+ with :
33+ # we need the whole thing so we can count commits.
34+ fetch-depth : " 0"
2935
30- steps :
31- - name : Checkout repository
32- uses : actions/checkout@v6
33- with :
34- # we need the whole thing so we can count commits.
35- fetch-depth : ' 0'
36+ - name : Set up QEMU
37+ uses : docker/setup-qemu-action@v3
38+ with :
39+ platforms : " arm64"
3640
37- - name : Set up QEMU
38- uses : docker/setup-qemu-action@v3
39- with :
40- platforms : ' arm64'
41+ # Workaround: https://github.com/docker/build-push-action/issues/461
42+ - name : Setup Docker buildx
43+ uses : docker/setup-buildx-action@v3
4144
42- # Workaround: https://github.com/docker/build-push-action/issues/461
43- - name : Setup Docker buildx
44- uses : docker/setup-buildx-action@v3
45+ # Login against a Docker registry except on PR
46+ # https://github.com/docker/login-action
47+ - name : Log into registry ${{ env.REGISTRY }}
48+ if : github.event_name != 'pull_request'
49+ uses : docker/login-action@v3
50+ with :
51+ registry : ${{ env.REGISTRY }}
52+ username : ${{ github.actor }}
53+ password : ${{ secrets.GITHUB_TOKEN }}
4554
46- # Login against a Docker registry except on PR
47- # https://github.com/docker/login-action
48- - name : Log into registry ${{ env.REGISTRY }}
49- if : github.event_name != 'pull_request'
50- uses : docker/login-action@v3
51- with :
52- registry : ${{ env.REGISTRY }}
53- username : ${{ github.actor }}
54- password : ${{ secrets.GITHUB_TOKEN }}
55+ # Extract metadata (tags, labels) for Docker
56+ # https://github.com/docker/metadata-action
57+ - name : Extract Docker metadata
58+ id : meta
59+ uses : docker/metadata-action@v5
60+ with :
61+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5562
56- # Extract metadata (tags, labels) for Docker
57- # https://github.com/docker/metadata-action
58- - name : Extract Docker metadata
59- id : meta
60- uses : docker/metadata-action@v5
61- with :
62- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
63+ - name : More Docker metadata
64+ run : |
65+ echo BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:00Z) >> $GITHUB_ENV
66+ echo COMMITS=$(git rev-list --count --all || echo 0) >> $GITHUB_ENV
6367
64- - name : More Docker metadata
65- run : |
66- echo BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:00Z) >> $GITHUB_ENV
67- echo COMMITS=$(git rev-list --count --all || echo 0) >> $GITHUB_ENV
68-
69- # Build and push Docker image with Buildx (don't push on PR)
70- # https://github.com/docker/build-push-action
71- - name : Build and push Docker image
72- id : build-and-push
73- uses : docker/build-push-action@v6
74- with :
75- context : .
76- file : docker/Dockerfile
77- platforms : linux/amd64,linux/arm64
78- push : ${{ github.event_name != 'pull_request' }}
79- tags : ${{ steps.meta.outputs.tags }}
80- labels : ${{ steps.meta.outputs.labels }}
81- cache-from : type=gha
82- cache-to : type=gha,mode=max
83- build-args : |
84- "BUILD_DATE=${{ env.BUILD_DATE }}"
85- "COMMITS=${{ env.COMMITS }}"
86- "BRANCH=${{ github.ref_name }}"
87- "COMMIT=${{ github.sha }}"
68+ # Build and push Docker image with Buildx (don't push on PR)
69+ # https://github.com/docker/build-push-action
70+ - name : Build and push Docker image
71+ id : build-and-push
72+ uses : docker/build-push-action@v6
73+ with :
74+ context : .
75+ file : docker/Dockerfile
76+ platforms : linux/amd64,linux/arm64
77+ push : ${{ github.event_name != 'pull_request' }}
78+ tags : ${{ steps.meta.outputs.tags }}
79+ labels : ${{ steps.meta.outputs.labels }}
80+ cache-from : type=gha
81+ cache-to : type=gha,mode=max
82+ build-args : |
83+ "BUILD_DATE=${{ env.BUILD_DATE }}"
84+ "COMMITS=${{ env.COMMITS }}"
85+ "BRANCH=${{ github.ref_name }}"
86+ "COMMIT=${{ github.sha }}"
0 commit comments