Skip to content

Commit bf48c2b

Browse files
committed
updated workflow
1 parent be6aa02 commit bf48c2b

1 file changed

Lines changed: 40 additions & 12 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ name: Build and Publish Docker Image
22

33
on:
44
push:
5-
branches: [ main ]
6-
tags: [ 'v*' ]
5+
branches:
6+
- main
7+
- develop
8+
tags:
9+
- 'v*'
710
pull_request:
8-
branches: [ main ]
11+
branches:
12+
- main
13+
- develop
914

1015
env:
1116
REGISTRY: ghcr.io
@@ -20,31 +25,54 @@ jobs:
2025

2126
steps:
2227
- name: Checkout repository
23-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
2432

2533
- name: Log in to the Container registry
26-
uses: docker/login-action@v2
34+
uses: docker/login-action@v3
2735
with:
2836
registry: ${{ env.REGISTRY }}
2937
username: ${{ github.actor }}
3038
password: ${{ secrets.GITHUB_TOKEN }}
3139

3240
- name: Extract metadata
3341
id: meta
34-
uses: docker/metadata-action@v4
42+
uses: docker/metadata-action@v5
3543
with:
3644
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3745
tags: |
38-
type=ref,event=branch
39-
type=ref,event=pr
46+
# For main branch - gets 'latest' tag
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
49+
# For develop branch - gets 'dev' tag
50+
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/develop' }}
51+
52+
# For version tags (v1.0.0) - gets version tags
4053
type=semver,pattern={{version}}
4154
type=semver,pattern={{major}}.{{minor}}
42-
type=raw,value=latest,enable={{is_default_branch}}
55+
type=semver,pattern={{major}}
56+
57+
# For PRs - gets pr-NUMBER tag
58+
type=ref,event=pr
59+
60+
# Add branch name for any branch
61+
type=ref,event=branch
62+
63+
# Add short SHA for all builds
64+
type=sha,prefix={{branch}}-,format=short
4365
4466
- name: Build and push Docker image
45-
uses: docker/build-push-action@v4
67+
uses: docker/build-push-action@v5
4668
with:
4769
context: .
48-
push: true
70+
platforms: linux/amd64,linux/arm64
71+
push: ${{ github.event_name != 'pull_request' }}
4972
tags: ${{ steps.meta.outputs.tags }}
50-
labels: ${{ steps.meta.outputs.labels }}
73+
labels: ${{ steps.meta.outputs.labels }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max
76+
# Optional: Use BuildKit inline cache
77+
build-args: |
78+
BUILDKIT_INLINE_CACHE=1

0 commit comments

Comments
 (0)