24
24
attestations : write
25
25
id-token : write
26
26
27
+ env :
28
+ BUILD_IMAGE : true
29
+
27
30
steps :
28
31
- name : Checkout repository
29
32
uses : actions/checkout@v4
@@ -81,12 +84,14 @@ jobs:
81
84
82
85
if git diff --staged --quiet; then
83
86
echo "No changes to commit"
87
+ echo "BUILD_IMAGE=false" >> $GITHUB_ENV
84
88
else
85
89
git commit -m "Update metadata.json"
86
90
git push origin main
87
91
fi
88
92
89
93
- name : Check if Dockerfile exists
94
+ if : env.BUILD_IMAGE == 'true'
90
95
id : check-dockerfile
91
96
shell : bash
92
97
run : |
@@ -97,26 +102,33 @@ jobs:
97
102
fi
98
103
99
104
- name : Log in to the Container registry
100
- if : steps.check-dockerfile.outputs.exists == 'true'
105
+ if : |
106
+ env.BUILD_IMAGE == 'true' &&
107
+ steps.check-dockerfile.outputs.exists == 'true'
101
108
uses : docker/login-action@v3
102
109
with :
103
110
registry : ${{ env.REGISTRY }}
104
111
username : ${{ github.actor }}
105
112
password : ${{ secrets.GITHUB_TOKEN }}
106
113
107
114
- name : Extract metadata (tags, labels) for Docker
108
- if : steps.check-dockerfile.outputs.exists == 'true'
115
+ if : |
116
+ env.BUILD_IMAGE == 'true' &&
117
+ steps.check-dockerfile.outputs.exists == 'true'
109
118
id : meta
110
119
uses : docker/metadata-action@v5
111
120
with :
112
121
images : ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}
113
122
114
123
- name : Set up Docker Buildx
115
- if : steps.check-dockerfile.outputs.exists == 'true'
124
+ if : |
125
+ env.BUILD_IMAGE == 'true' &&
126
+ steps.check-dockerfile.outputs.exists == 'true'
116
127
uses : docker/setup-buildx-action@v3
117
128
118
129
- name : Build and push Docker image - multi-platform
119
130
if : |
131
+ env.BUILD_IMAGE == 'true' &&
120
132
steps.check-dockerfile.outputs.exists == 'true' &&
121
133
steps.platform.outputs.supports_multiplatform == 'true'
122
134
id : push-multiplatform
@@ -131,6 +143,7 @@ jobs:
131
143
132
144
- name : Generate artifact attestation - multi-platform
133
145
if : |
146
+ env.BUILD_IMAGE == 'true' &&
134
147
steps.check-dockerfile.outputs.exists == 'true' &&
135
148
steps.platform.outputs.supports_multiplatform == 'true'
136
149
uses : actions/attest-build-provenance@v2
@@ -141,6 +154,7 @@ jobs:
141
154
142
155
- name : Build and push Docker image - amd64 only
143
156
if : |
157
+ env.BUILD_IMAGE == 'true' &&
144
158
steps.check-dockerfile.outputs.exists == 'true' &&
145
159
steps.platform.outputs.supports_multiplatform == 'false'
146
160
id : push-amd64
@@ -155,6 +169,7 @@ jobs:
155
169
156
170
- name : Generate artifact attestation - amd64 only
157
171
if : |
172
+ env.BUILD_IMAGE == 'true' &&
158
173
steps.check-dockerfile.outputs.exists == 'true' &&
159
174
steps.platform.outputs.supports_multiplatform == 'false'
160
175
uses : actions/attest-build-provenance@v2
0 commit comments