55 - main
66permissions : {}
77jobs :
8- build-snapshot :
8+ build :
99 permissions :
10+ # checkout
1011 contents : read
12+ # push PR image
13+ packages : write
1114 runs-on : ubuntu-latest
1215 steps :
1316 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -16,59 +19,20 @@ jobs:
1619 - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
1720 with :
1821 go-version : stable
19- - uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
20- id : goreleaser
21- with :
22- version : latest
23- args : build --clean --verbose --single-target --snapshot
24- - name : tar up binaries
25- run : tar -cvf dist.tar dist
26- - uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
27- with :
28- path : dist.tar
29- build-image :
30- permissions :
31- contents : read
32- packages : write
33- runs-on : ubuntu-latest
34- needs : build-snapshot
35- strategy :
36- matrix :
37- binary :
38- - go-cli-github
39- - another-binary
40- steps :
41- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
42- with :
43- ref : ${{ github.event.pull_request.head.sha }}
44- - uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
45- - name : untar binaries
46- run : tar -xvf dist.tar
22+ - uses : docker/setup-buildx-action@v3
4723 - name : Login to GHCR
48- if : github.actor != 'dependabot[bot]'
4924 uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
5025 with :
5126 registry : ghcr.io
5227 username : ${{ github.repository_owner }}
5328 password : ${{ secrets.GITHUB_TOKEN }}
54- - name : Get Docker metadata
55- if : github.actor != 'dependabot[bot]'
56- id : docker_metadata
57- uses : docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
58- with :
59- images : ghcr.io/${{ github.repository }}/${{ matrix.binary }}
60- - name : Build and push ${{ matrix.binary }} container image
61- if : github.actor != 'dependabot[bot]'
62- uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
29+ - uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
30+ id : goreleaser
31+ env :
32+ PR_NUMBER : ${{ github.event.number }}
6333 with :
64- push : true
65- tags : ${{ steps.docker_metadata.outputs.tags }}
66- labels : ${{ steps.docker_metadata.outputs.labels }}
67- file : Dockerfile
68- build-args : |
69- BINARY=${{ matrix.binary }}
70- TARGETPLATFORM=${{ matrix.binary }}_linux_amd64_v1
71- context : dist
34+ version : latest
35+ args : build --clean --verbose --single-target
7236 check-tag :
7337 permissions :
7438 contents : read
0 commit comments