Skip to content

Commit 84e05da

Browse files
authored
Add metadata-action so labels are generated
1 parent 8c76aad commit 84e05da

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

.github/workflows/docker.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,16 @@ 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
5250
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
@@ -58,9 +56,8 @@ jobs:
5856
context: .
5957
platforms: ${{ env.PLATFORMS }}
6058
push: true
61-
tags: |
62-
ghcr.io/${{ env.GHCR_NAMESPACE }}/sliding-sync:latest
63-
ghcr.io/${{ env.GHCR_NAMESPACE }}/sliding-sync:${{ github.ref_name }}
59+
tags: ${{ steps.metadata.outputs.tags }}
60+
labels: ${{ steps.metadata.outputs.labels }}
6461

6562
- name: Run Trivy vulnerability scanner
6663
uses: aquasecurity/trivy-action@master

0 commit comments

Comments
 (0)