@@ -156,6 +156,9 @@ jobs:
156
156
-
157
157
name : Checkout
158
158
uses : actions/checkout@v2.3.4
159
+ with :
160
+ # To identify the commit we need the history and all teh tags.
161
+ fetch-depth : 0
159
162
-
160
163
name : Build meta
161
164
id : build-meta
@@ -179,9 +182,17 @@ jobs:
179
182
else
180
183
labels='quay.expires-after=7d'
181
184
fi
185
+ commit_sha=${{ github.event.pull_request.head.sha || github.sha }}
186
+ commit_date=$(git log -1 --pretty=format:'%ad' --date short "${commit_sha}")
187
+ # use git describe to get the nearest tag and use that to build the version (e.g. 1.4.0+dev24 or 1.4.0)
188
+ commit_version=$(git describe --tags --match 'v*' "${commit_sha}"| sed -e 's/^v//; s/-g[0-9a-f]\+$//; s/-\([0-9]\+\)$/+dev\1/')
189
+ commit_short=$(git rev-parse --short "${commit_sha}")
182
190
echo "::set-output name=images::${images}"
183
191
echo "::set-output name=tags::${tags}"
184
192
echo "::set-output name=labels::${labels}"
193
+ echo "::set-output name=date::${commit_date}"
194
+ echo "::set-output name=version::${commit_version}"
195
+ echo "::set-output name=commit::${commit_short}"
185
196
-
186
197
name : Docker meta
187
198
id : docker-meta
@@ -219,6 +230,10 @@ jobs:
219
230
# Available architecture on UBI8 are: linux/amd64, linux/arm64, linux/ppc64le
220
231
platforms : linux/amd64
221
232
push : true
233
+ build-args : |
234
+ DATE=${{ steps.build-meta.outputs.date }}
235
+ COMMIT=${{ steps.build-meta.outputs.commit }}
236
+ VERSION=${{ steps.build-meta.outputs.version }}
222
237
tags : ${{ steps.docker-meta.outputs.tags }}
223
238
labels : ${{ steps.build-meta.outputs.labels }}
224
239
-
0 commit comments