Skip to content

Commit eff4ecc

Browse files
committed
[GitHub] add Docker labels, tags, and build args
1 parent 28db265 commit eff4ecc

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

.github/workflows/deploy-image.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,27 @@ jobs:
2525
- name: Set Environmental Variables
2626
run: |
2727
echo Repository: $REPOSITORY
28+
2829
export IMAGE_NAME=${REPOSITORY//docker-/}
2930
echo Image Name: $IMAGE_NAME
3031
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
3132
33+
export VERSION=$(git describe --tags --always)
34+
echo Version: $VERSION
35+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
36+
37+
export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
38+
echo Build Date: $BUILD_DATE
39+
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_ENV
40+
3241
3342
- name: Checkout repository
3443
uses: actions/checkout@v2
3544

36-
- name: Log in to the Container registry
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v1
47+
48+
- name: Log in to the (GitHub) Container registry
3749
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
3850
with:
3951
registry: ${{ env.REGISTRY }}
@@ -45,11 +57,22 @@ jobs:
4557
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
4658
with:
4759
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60+
tags: |
61+
type=semver,pattern={{version}}
62+
type=semver,pattern={{major}}.{{minor}}
63+
type=semver,pattern={{major}}
64+
type=sha
4865
4966
- name: Build and push Docker image
5067
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
5168
with:
5269
context: .
70+
build_args: |
71+
VERSION=${{ env.VERSION }}
72+
COMMIT=${{ github.sha }}
73+
URL=${{ github.repositoryUrl }}
74+
BRANCH=${{ github.ref_name }}
75+
BUILD_DATE=${{ env.BUILD_DATE }}
5376
push: true
5477
tags: ${{ steps.meta.outputs.tags }}
5578
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)