Skip to content

Commit a998e70

Browse files
committed
Switch to using docker/metadata action to make sure labels are populated
* Swapped custom dockertag from ref to semver/sha * Support publishing images from non main repo (easier to test)
1 parent c9b2ac5 commit a998e70

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v5
1515

16-
- name: Generate Docker Tag
17-
run: |
18-
echo ${{ github.ref }} | cut -d '/' -f 3 > DOCKER_TAG
19-
echo "DOCKER_TAG=$(cat DOCKER_TAG)" >> $GITHUB_ENV
20-
2116
- name: Set up QEMU
2217
uses: docker/setup-qemu-action@v3
2318

@@ -26,6 +21,7 @@ jobs:
2621

2722
- name: Login to Docker Hub
2823
uses: docker/login-action@v3
24+
if: ${{ github.repository == 'movetokube/postgres-operator' }}
2925
with:
3026
username: ${{ secrets.DOCKER_USER }}
3127
password: ${{ secrets.DOCKER_TOKEN }}
@@ -37,14 +33,24 @@ jobs:
3733
username: ${{ github.repository_owner }}
3834
password: ${{ secrets.GITHUB_TOKEN }}
3935

36+
- name: Docker meta
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: |
41+
ghcr.io/${{ github.repository }}
42+
movetokube/postgres-operator,enable=${{ github.repository == 'movetokube/postgres-operator' }}
43+
tags: |
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=semver
47+
type=sha
48+
4049
- name: Build and push
4150
uses: docker/build-push-action@v6
4251
with:
4352
context: .
4453
platforms: linux/amd64,linux/arm64
4554
push: true
46-
tags: |
47-
ghcr.io/movetokube/postgres-operator:latest
48-
ghcr.io/movetokube/postgres-operator:${{ env.DOCKER_TAG }}
49-
movetokube/postgres-operator:${{ env.DOCKER_TAG }}
50-
movetokube/postgres-operator:latest
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)