Skip to content

Commit 75d5ca9

Browse files
committed
Add metadata-action so labels are generated
Signed-off-by: Gavin Mogan <[email protected]>
1 parent 8c76aad commit 75d5ca9

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

.github/workflows/docker.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,28 @@ jobs:
3535
username: ${{ github.repository_owner }}
3636
password: ${{ secrets.GITHUB_TOKEN }}
3737

38-
- name: Build main sliding sync image
39-
if: github.ref_name == 'main'
40-
id: docker_build_sliding_sync
41-
uses: docker/build-push-action@v4
38+
- name: Generate docker image tags
39+
id: metadata
40+
uses: docker/metadata-action@v5
4241
with:
43-
cache-from: type=gha
44-
cache-to: type=gha,mode=max
45-
context: .
46-
platforms: ${{ env.PLATFORMS }}
47-
push: true
42+
images: |
43+
name=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}
4844
tags: |
49-
ghcr.io/${{ env.GHCR_NAMESPACE }}/sliding-sync:main
45+
${{ github.ref_name == 'main' && 'type=raw,value=main' }}
46+
${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && 'type=raw,value=latest' }}
47+
type=raw,value=${{ github.ref_name }}
5048
5149
- name: Build release Sliding Sync image
52-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
5350
id: docker_build_sliding_sync_release
5451
uses: docker/build-push-action@v4
5552
with:
5653
cache-from: type=gha
5754
cache-to: type=gha,mode=max
5855
context: .
5956
platforms: ${{ env.PLATFORMS }}
60-
push: true
61-
tags: |
62-
ghcr.io/${{ env.GHCR_NAMESPACE }}/sliding-sync:latest
63-
ghcr.io/${{ env.GHCR_NAMESPACE }}/sliding-sync:${{ github.ref_name }}
57+
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
58+
tags: ${{ steps.metadata.outputs.tags }}
59+
labels: ${{ steps.metadata.outputs.labels }}
6460

6561
- name: Run Trivy vulnerability scanner
6662
uses: aquasecurity/trivy-action@master

0 commit comments

Comments
 (0)