77env :
88 GOPATH : /home/runner/go/
99 GOPROXY : " https://proxy.golang.org"
10- REGISTRY_IMAGE : pluralsh/pluralsh/ pr-governance-webhook
10+ REGISTRY_IMAGE : pluralsh/pr-governance-webhook
1111jobs :
12+ build :
13+ name : Build
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v4
17+ - uses : actions/setup-go@v5
18+ with :
19+ go-version-file : go.mod
20+ check-latest : true
21+ - run : PATH=$PATH:$GOPATH/bin make build
1222 test :
1323 name : Unit test
1424 runs-on : ubuntu-latest
1929 go-version-file : go.mod
2030 check-latest : true
2131 - run : PATH=$PATH:$GOPATH/bin make test
32+ lint :
33+ name : Lint
34+ runs-on : ubuntu-latest
35+ steps :
36+ - uses : actions/checkout@v4
37+ - uses : actions/setup-go@v5
38+ with :
39+ go-version-file : go.mod
40+ check-latest : true
41+ -
uses :
golangci/[email protected] 42+ with :
43+ version : v2.1.2
2244 build-image :
2345 name : Build image
24- needs : [test]
46+ needs : [build, test]
2547 permissions :
2648 contents : ' read'
2749 id-token : ' write'
@@ -36,41 +58,54 @@ jobs:
3658 runner : ubuntu-24.04-arm
3759 runs-on : ${{ matrix.platforms.runner }}
3860 steps :
39- - name : Checkout
40- uses : actions/checkout@v4
41- with :
42- fetch-depth : 0
43- - name : Prepare
44- run : |
45- platform=${{ matrix.platforms.platform }}
46- echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
47- - name : Docker meta
48- id : meta
49- uses : docker/metadata-action@v5
50- with :
51- images : ${{ env.REGISTRY_IMAGE }}
52- - name : Set up QEMU
53- uses : docker/setup-qemu-action@v3
54- - name : Set up Docker Buildx
55- uses : docker/setup-buildx-action@v3
56- - name : Login to GHCR
57- uses : docker/login-action@v3
58- with :
59- registry : ghcr.io
60- username : ${{ github.repository_owner }}
61- password : ${{ secrets.GITHUB_TOKEN }}
62- - name : Export digest
63- run : |
64- mkdir -p ${{ runner.temp }}/digests
65- digest="${{ steps.build.outputs.digest }}"
66- touch "${{ runner.temp }}/digests/${digest#sha256:}"
67- - name : Upload digest
68- uses : actions/upload-artifact@v4
69- with :
70- name : digests-${{ env.PLATFORM_PAIR }}
71- path : ${{ runner.temp }}/digests/*
72- if-no-files-found : error
73- retention-days : 1
61+ - name : Checkout
62+ uses : actions/checkout@v4
63+ with :
64+ fetch-depth : 0
65+ - name : Prepare
66+ run : |
67+ platform=${{ matrix.platforms.platform }}
68+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
69+ - name : Docker meta
70+ id : meta
71+ uses : docker/metadata-action@v5
72+ with :
73+ images : ${{ env.REGISTRY_IMAGE }}
74+ - name : Set up QEMU
75+ uses : docker/setup-qemu-action@v3
76+ - name : Set up Docker Buildx
77+ uses : docker/setup-buildx-action@v3
78+ - name : Login to Docker Hub
79+ uses : docker/login-action@v3
80+ with :
81+ username : mjgpluralsh
82+ password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
83+ - name : Build and push by digest
84+ id : build
85+ uses : docker/build-push-action@v6
86+ with :
87+ context : " ."
88+ file : " ./Dockerfile"
89+ tags : ${{ env.REGISTRY_IMAGE }}
90+ labels : ${{ steps.meta.outputs.labels }}
91+ platforms : ${{ matrix.platforms.platform }}
92+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
93+ cache-from : type=gha
94+ cache-to : type=gha,mode=max
95+ build-args : |
96+ GIT_COMMIT=${{ github.sha }}
97+ - name : Export digest
98+ run : |
99+ mkdir -p ${{ runner.temp }}/digests
100+ digest="${{ steps.build.outputs.digest }}"
101+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
102+ - name : Upload digest
103+ uses : actions/upload-artifact@v4
104+ with :
105+ name : digests-${{ env.PLATFORM_PAIR }}
106+ path : ${{ runner.temp }}/digests/*
107+ if-no-files-found : error
108+ retention-days : 1
74109 publish-image :
75110 name : Publish image
76111 needs : [build-image]
@@ -96,10 +131,10 @@ jobs:
96131 with :
97132 images : |
98133 ghcr.io/pluralsh/pr-governance-webhook
99- tags : type=semver,pattern={{version}}
134+ tags : |
135+ tags: type=semver,pattern={{version}}
100136 - name : Create manifest list and push
101137 working-directory : ${{ runner.temp }}/digests
102138 run : |
103139 docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
104- $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
105-
140+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
0 commit comments