Skip to content

Commit 96e52f2

Browse files
committed
docker-latest workflow updates. Release workflow refactor, add latest tag on release
1 parent 37a686d commit 96e52f2

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

.github/workflows/docker-latest.yml

+41-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,33 @@ on:
88
push:
99
branches:
1010
- master
11+
1112
jobs:
13+
check_commit:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
should_run: ${{ steps.check_commit_message.outputs.should_run }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 2
22+
23+
- name: Check commit message
24+
id: check_commit_message
25+
run: |
26+
COMMIT_MSG=$(git log -1 --pretty=%s)
27+
if [[ "$COMMIT_MSG" == chore* ]]; then
28+
echo "should_run=false" >> $GITHUB_OUTPUT
29+
echo "Skipping workflow for commit: $COMMIT_MSG"
30+
else
31+
echo "should_run=true" >> $GITHUB_OUTPUT
32+
echo "Running workflow for commit: $COMMIT_MSG"
33+
fi
34+
1235
docker:
36+
needs: check_commit
37+
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
1338
runs-on: ubuntu-latest
1439
steps:
1540
- name: Checkout
@@ -33,11 +58,22 @@ jobs:
3358
username: ${{ github.repository_owner }}
3459
password: ${{ secrets.GITHUB_TOKEN }}
3560

36-
- name: Build and push
37-
uses: docker/build-push-action@v5
61+
- name: Extract metadata (tags, labels) for Docker
62+
id: meta
63+
uses: docker/metadata-action@v5
64+
with:
65+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
66+
flavor: |
67+
latest=false
68+
tags: |
69+
type=raw,value=latest
70+
71+
- name: Build and push Docker image
72+
uses: docker/build-push-action@v6
73+
id: push
3874
with:
3975
context: .
40-
platforms: ${{ steps.buildx.outputs.platforms }}
4176
push: true
42-
tags: |
43-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
77+
platforms: ${{ steps.buildx.outputs.platforms }}
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ jobs:
2929
package-name: ${{env.NPM_MODULE_NAME}}
3030
pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
3131
# The logic below handles the npm publication:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v3
3333
# these if statements ensure that a publication only occurs when
3434
# a new release is created:
3535
if: ${{ steps.release.outputs.release_created }}
36-
- uses: actions/setup-node@v4
36+
- uses: actions/setup-node@v3
3737
with:
3838
node-version: 18
3939
registry-url: 'https://registry.npmjs.org'
@@ -88,7 +88,7 @@ jobs:
8888
with:
8989
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
9090
flavor: |
91-
latest=false
91+
latest=auto
9292
tags: |
9393
type=semver,pattern={{version}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
9494
type=semver,pattern={{major}}.{{minor}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
@@ -109,5 +109,4 @@ jobs:
109109
with:
110110
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
111111
subject-digest: ${{ steps.push.outputs.digest }}
112-
push-to-registry: true
113112
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)