Skip to content

Commit 6f2c86b

Browse files
committed
feat: update GitHub workflow for Docker image publishing with linting and multi-platform support
1 parent ea74fc2 commit 6f2c86b

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

.github/workflows/docker-publish.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66
branches:
77
- main
88
- develop
9-
- "feature/**"
10-
- "hotfix/**"
9+
- 'feature/**'
10+
- 'hotfix/**'
1111
tags:
12-
- "v*.*.*"
12+
- 'v*.*.*'
1313
pull_request:
1414
branches:
1515
- main
@@ -20,21 +20,21 @@ env:
2020
IMAGE_NAME: ${{ github.repository }}
2121

2222
jobs:
23-
# lint:
24-
# name: Lint Dockerfile
25-
# runs-on: ubuntu-latest
26-
# steps:
27-
# - name: Checkout code
28-
# uses: actions/checkout@v4
23+
lint:
24+
name: Lint Dockerfile
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
2929

30-
# - name: Lint Dockerfile
31-
# uses: hadolint/[email protected]
32-
# with:
33-
# dockerfile: Dockerfile
30+
- name: Lint Dockerfile
31+
uses: hadolint/[email protected]
32+
with:
33+
dockerfile: Dockerfile
3434

3535
build-and-push:
3636
name: Build and Push Docker image
37-
# needs: lint
37+
needs: lint
3838
runs-on: ubuntu-latest
3939
permissions:
4040
contents: read
@@ -44,6 +44,13 @@ jobs:
4444
- name: Checkout code
4545
uses: actions/checkout@v4
4646

47+
- name: Extract short SHA
48+
id: vars
49+
run: echo "sha_short=$(git rev-parse --short=7 ${{ github.sha }})" >> $GITHUB_OUTPUT
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@v3
53+
4754
- name: Set up Docker Buildx
4855
uses: docker/setup-buildx-action@v3
4956

@@ -60,7 +67,7 @@ jobs:
6067
with:
6168
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6269
tags: |
63-
type=sha,format=long
70+
type=raw,value=sha-${{ steps.vars.outputs.sha_short }}
6471
type=ref,event=branch
6572
type=ref,event=pr
6673
type=semver,pattern={{version}}
@@ -72,14 +79,18 @@ jobs:
7279
uses: docker/build-push-action@v5
7380
with:
7481
context: .
82+
platforms: linux/amd64,linux/arm64
7583
push: ${{ github.event_name != 'pull_request' }}
7684
tags: ${{ steps.meta.outputs.tags }}
7785
labels: ${{ steps.meta.outputs.labels }}
7886
cache-from: type=gha
7987
cache-to: type=gha,mode=max
8088

81-
- name: Print image tags
89+
- name: Print image details
8290
if: github.event_name != 'pull_request'
8391
run: |
8492
echo "Published tags:"
8593
echo "${{ steps.meta.outputs.tags }}" | tr ' ' '\n'
94+
echo -e "\nPlatforms:"
95+
echo "- linux/amd64"
96+
echo "- linux/arm64"

0 commit comments

Comments
 (0)