4
4
workflow_dispatch :
5
5
schedule :
6
6
- cron : " 0 0 * * *"
7
+ pull_request :
8
+ branches :
9
+ - ' dev'
7
10
push :
8
11
tags :
9
12
- ' v*.*.*'
10
13
14
+ env :
15
+ REGISTRY : ghcr.io
16
+ IMAGE_NAME : ${{ github.repository }}
17
+
18
+
11
19
jobs :
12
- build :
13
- name : Buid and push Docker image to GitHub Container registry
20
+ build-and-push-image :
14
21
runs-on : ubuntu-latest
15
22
permissions :
16
23
contents : read
17
24
packages : write
18
25
attestations : write
19
26
id-token : write
20
-
27
+
21
28
steps :
22
- - name : Checkout the repository
29
+ - name : Checkout repository
23
30
uses : actions/checkout@v4
24
31
25
- - name : Get current date
26
- id : date
27
- run : echo "::set-output name=date::$(date +'%Y%m%d')"
28
-
29
- - name : Set up QEMU
30
- uses : docker/setup-qemu-action@v3
31
- - name : Set up Docker Buildx
32
- uses : docker/setup-buildx-action@v3
33
-
34
- - name : Login to GitHub Container Registry
35
- uses : docker/login-action@v3
32
+ - name : Log in to the Container registry
33
+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
36
34
with :
37
- registry : ghcr.io
38
- username : ${{ github.repository_owner }}
39
- password : ${{ secrets.GH_TOKEN }}
40
-
41
- - name : Build Nightly Meta
42
- run : |
43
- echo "DEVELOPMENT_TAG=ghcr.io/barelyhuman/goblin:nightly-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
44
-
45
- - name : Build Release Meta
46
- run : |
47
- echo "RELEASE_TAG=ghcr.io/barelyhuman/goblin:${{ github.ref_name }}" >> $GITHUB_ENV
48
- if : github.ref_type == 'tag'
35
+ registry : ${{ env.REGISTRY }}
36
+ username : ${{ github.actor }}
37
+ password : ${{ secrets.GITHUB_TOKEN }}
38
+
39
+ - name : Extract metadata (tags, labels) for Docker
40
+ id : meta
41
+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
42
+ with :
43
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44
+ tags : |
45
+ type=ref,event=branch
46
+ type=ref,event=pr
47
+ type=semver,pattern={{version}}
48
+ type=semver,pattern={{major}}.{{minor}}
49
49
50
- - name : Build and push nightly
51
- uses : docker/build-push-action@v6
50
+ - name : Build and push Docker image
52
51
id : push
53
- env :
54
- REGISTRY : ghcr.io
55
- OWNER : ${{ github.repository_owner }}
56
- IMAGE_NAME : ${{ github.repository }}
57
- with :
58
- context : .
59
- file : Dockerfile
60
- platforms : linux/amd64,linux/arm64
61
- push : true
62
- tags : ${{ env.DEVELOPMENT_TAG }},nightly
63
-
64
- - name : Build and push release tag
65
- if : github.ref_type == 'tag'
66
- uses : docker/build-push-action@v6
67
- id : pushRelease
68
- env :
69
- REGISTRY : ghcr.io
70
- OWNER : ${{ github.repository_owner }}
71
- IMAGE_NAME : ${{ github.repository }}
52
+ uses : docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
72
53
with :
73
54
context : .
74
- file : Dockerfile
75
- platforms : linux/amd64,linux/arm64
76
55
push : true
77
- tags : ${{ env.RELEASE_TAG }}
78
-
56
+ tags : ${{ steps.meta.outputs.tags }}
57
+ labels : ${{ steps.meta.outputs.labels }}
58
+
79
59
- name : Generate artifact attestation
80
60
uses : actions/attest-build-provenance@v1
81
61
with :
82
- subject-name : ghcr.io/barelyhuman/goblin
62
+ subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
83
63
subject-digest : ${{ steps.push.outputs.digest }}
84
- push-to-registry : true
85
-
86
- - name : Generate release artifact attestation
87
- if : github.ref_type == 'tag'
88
- uses : actions/attest-build-provenance@v1
89
- with :
90
- subject-name : ghcr.io/barelyhuman/goblin
91
- subject-digest : ${{ steps.pushRelease.outputs.digest }}
92
64
push-to-registry : true
0 commit comments