@@ -2,14 +2,8 @@ name: Build Image golang
22
33on :
44 push :
5- branches :
6- - dev
7- tags :
8- - " *"
95 paths :
106 - ' golang/*'
11- schedule :
12- - cron : " 15 4 1 * *"
137
148jobs :
159 build :
@@ -27,13 +21,10 @@ jobs:
2721 uses : docker/metadata-action@v5
2822 with :
2923 images : |
30- mtr.devops.telekom.de/mcsps/golang
3124 ghcr.io/mcsps/golang
3225 tags : |
33- type=ref,event=tag
34- type=ref,event=branch
35- type=ref,event=pr
3626 type=raw,value=latest
27+ type=semver,pattern={{version}},value=1.25.0 # change also in the Dockerfile
3728 - name : Install Cosign
3829 uses : sigstore/cosign-installer@main
3930 with :
@@ -42,32 +33,32 @@ jobs:
4233 uses : docker/setup-qemu-action@v3
4334 - name : Set up Docker Buildx
4435 uses : docker/setup-buildx-action@v3
45- - name : Login to MTR
46- uses : docker/login-action@v3
47- with :
48- registry : mtr.devops.telekom.de
49- username : ${{ secrets.MTR_USERNAME }}
50- password : ${{ secrets.MTR_PASSWORD }}
5136 - name : Login to GitHub Container Registry
5237 uses : docker/login-action@v3
5338 with :
5439 registry : ghcr.io
5540 username : ${{ github.repository_owner }}
5641 password : ${{ secrets.GITHUB_TOKEN }}
57- - name : Build and push
42+ - name : Build (PR only)
43+ if : github.event_name == 'pull_request'
44+ uses : docker/build-push-action@v5
45+ with :
46+ context : ./golang
47+ platforms : linux/amd64,linux/arm64
48+ push : false
49+ - name : Build and push (merge only)
50+ if : github.event_name == 'push'
5851 uses : docker/build-push-action@v5
59- id : build-push
6052 with :
6153 context : ./golang
6254 platforms : linux/amd64,linux/arm64
6355 push : true
6456 tags : |
65- mtr.devops.telekom.de/mcsps/golang:latest
6657 ghcr.io/mcsps/golang:latest
6758 ${{ steps.meta.outputs.tags }}
6859 - name : Sign Push
60+ if : github.event_name == 'push'
6961 run : |
70- cosign sign --key env://COSIGN_KEY --tlog-upload=false mtr.devops.telekom.de/mcsps/golang@${{ steps.build-push.outputs.digest }}
7162 cosign sign --key env://COSIGN_KEY --tlog-upload=false ghcr.io/mcsps/golang@${{ steps.build-push.outputs.digest }}
7263 env :
7364 COSIGN_KEY : ${{secrets.COSIGN_KEY}}
0 commit comments