Skip to content

Commit b279b97

Browse files
author
Luis Rodríguez
committed
ci: Update GitHub workflow to build and push on PR merge
- Add trigger for PR merge to master branch - Update Docker action versions - Add more comprehensive tag strategy
1 parent c3a247a commit b279b97

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ name: Publish Docker image
33
on:
44
release:
55
types: [published]
6+
pull_request:
7+
types: [closed]
8+
branches: [master]
69

710
jobs:
811
push_to_registries:
12+
if: github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
913
name: Push Docker image to multiple registries
1014
runs-on: ubuntu-latest
1115
permissions:
@@ -22,21 +26,26 @@ jobs:
2226
uses: docker/setup-buildx-action@v2
2327

2428
- name: Log in to the Container registry
25-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
29+
uses: docker/login-action@v2
2630
with:
2731
registry: ghcr.io
2832
username: ${{ github.actor }}
2933
password: ${{ secrets.GITHUB_TOKEN }}
3034

3135
- name: Extract metadata (tags, labels) for Docker
3236
id: meta
33-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
37+
uses: docker/metadata-action@v4
3438
with:
3539
images: |
3640
ghcr.io/${{ github.repository }}
41+
tags: |
42+
type=semver,pattern={{version}}
43+
type=ref,event=branch
44+
type=sha,format=short
45+
latest
3746
3847
- name: Build and push Docker images
39-
uses: docker/build-push-action@v3
48+
uses: docker/build-push-action@v4
4049
with:
4150
context: .
4251
push: true

0 commit comments

Comments
 (0)