1+ name : Build Docker Image
2+
3+ on :
4+ push :
5+ branches : [main, dev, ci]
6+ tags :
7+ - ' v*'
8+
9+ env :
10+ REGISTRY : ghcr.io
11+ IMAGE_NAME : ${{ github.repository_owner }}/demos
12+
13+ jobs :
14+ publish :
15+ name : Build and publish Docker image
16+ runs-on : ubuntu-latest
17+ if : github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'
18+ permissions :
19+ contents : read
20+ packages : write
21+
22+ steps :
23+ - uses : actions/checkout@v4
24+
25+ - name : Log in to GHCR
26+ uses : docker/login-action@v3
27+ with :
28+ registry : ${{ env.REGISTRY }}
29+ username : ${{ github.actor }}
30+ password : ${{ secrets.GITHUB_TOKEN }}
31+
32+ - name : Set up QEMU
33+ uses : docker/setup-qemu-action@v3
34+
35+ - name : Set up Buildx
36+ uses : docker/setup-buildx-action@v3
37+
38+ - name : Docker meta (tags)
39+ id : meta
40+ uses : docker/metadata-action@v5
41+ with :
42+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+ tags : |
44+ type=sha,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
45+ type=ref,event=branch
46+ type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
47+ type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
48+
49+ - run : echo "${{ steps.meta.outputs.tags }}"
50+ - name : Build and push
51+ uses : docker/build-push-action@v6
52+ with :
53+ context : .
54+ push : true
55+ platforms : linux/amd64
56+ tags : ${{ steps.meta.outputs.tags }}
57+ labels : ${{ steps.meta.outputs.labels }}
58+ cache-from : type=gha
59+ cache-to : type=gha,mode=max
0 commit comments