1313 - " go.sum"
1414 release :
1515 types : [published]
16+ workflow_dispatch :
17+
18+ permissions :
19+ contents : read
20+ id-token : write
21+ packages : write
1622
1723jobs :
1824 build :
2127 - name : Checkout
2228 uses : actions/checkout@v4
2329
24- - name : Login to DockerHub
25- if : github.event_name != 'pull_request'
26- uses : docker/login-action@v3
27- with :
28- username : ${{ secrets.DOCKERHUB_USERNAME }}
29- password : ${{ secrets.DOCKERHUB_TOKEN }}
30-
31- - name : Login to GitHub Container Registry
32- if : github.event_name != 'pull_request'
33- uses : docker/login-action@v3
34- with :
35- registry : ghcr.io
36- username : ${{ github.actor }}
37- password : ${{ secrets.GITHUB_TOKEN }}
38-
3930 - name : Docker meta
4031 id : docker_meta
4132 uses : docker/metadata-action@v5
@@ -49,40 +40,70 @@ jobs:
4940 type=semver,pattern={{version}}
5041 type=semver,pattern={{major}}
5142 type=semver,pattern={{major}}.{{minor}}
43+ env :
44+ DOCKER_METADATA_ANNOTATIONS_LEVELS : manifest,index
45+
46+ - name : Install Cosign
47+ if : github.event_name != 'pull_request'
48+ uses : sigstore/cosign-installer@v3
5249
5350 - name : Set up QEMU
5451 uses : docker/setup-qemu-action@v3
5552
5653 - name : Set up Docker Buildx
5754 uses : docker/setup-buildx-action@v3
5855
59- - name : Go Build Cache for Docker layers
60- uses : actions/cache@v4
56+ - name : Login to DockerHub
57+ if : github.event_name != 'pull_request'
58+ uses : docker/login-action@v3
6159 with :
62- path : go-build-cache
63- key : ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
60+ username : ${{ secrets.DOCKERHUB_USERNAME }}
61+ password : ${{ secrets.DOCKERHUB_TOKEN }}
6462
65- - name : Inject go-build-cache into docker
66- uses : reproducible-containers/buildkit-cache-dance@v2.1.4
63+ - name : Login to GitHub Container Registry
64+ if : github.event_name != 'pull_request'
65+ uses : docker/login-action@v3
6766 with :
68- cache-source : go-build-cache
67+ registry : ghcr.io
68+ username : ${{ github.actor }}
69+ password : ${{ secrets.GITHUB_TOKEN }}
6970
7071 - name : Build and push
72+ id : docker_build
7173 uses : docker/build-push-action@v5
7274 with :
7375 context : .
74- file : ./Dockerfile
7576 platforms : linux/amd64,linux/arm/v7,linux/arm64
7677 push : ${{ github.event_name != 'pull_request' }}
77- tags : ${{ steps.docker_meta.outputs.tags }}
78+ annotations : ${{ steps.docker_meta.outputs.annotations }}
7879 labels : ${{ steps.docker_meta.outputs.labels }}
80+ tags : ${{ steps.docker_meta.outputs.tags }}
7981 cache-from : type=gha
8082 cache-to : type=gha,mode=max
83+ sbom : true
8184 build-args : |
8285 TibiaDataBuildBuilder=github
8386 TibiaDataBuildRelease=${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.version'] }}
8487 TibiaDataBuildCommit=${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.revision'] }}
8588
89+ - name : Sign the images (with GitHub OIDC Token)
90+ if : github.event_name != 'pull_request'
91+ run : |
92+ cosign sign --yes --recursive \
93+ tibiadata/tibiadata-api-go@${{ steps.docker_build.outputs.digest }}
94+
95+ cosign sign --yes --recursive \
96+ ghcr.io/tibiadata/tibiadata-api-go@${{ steps.docker_build.outputs.digest }}
97+
98+ dockerhub :
99+ if : github.event_name == 'release'
100+ runs-on : ubuntu-latest
101+ needs :
102+ - build
103+ steps :
104+ - name : Checkout
105+ uses : actions/checkout@v4
106+
86107 - name : Docker Hub Description
87108 uses : peter-evans/dockerhub-description@v4
88109 if : github.event_name == 'release'
0 commit comments