Skip to content

Commit b1925c4

Browse files
committed
Update workflows to use docker metadata
1 parent 161fde4 commit b1925c4

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

.github/workflows/backend.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,27 @@ jobs:
4949
username: ${{ github.actor }}
5050
password: ${{ github.token }}
5151

52+
- name: Docker metadata
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ghcr.io/javabin/cupcake
57+
tags: |
58+
type=ref,event=branch
59+
type=ref,event=tag
60+
type=sha,format=short
61+
type=raw,value=latest,enable={{is_default_branch}}
62+
5263
- name: Build and push
5364
uses: docker/build-push-action@v6
5465
with:
55-
context: ./backend
66+
context: .
5667
platforms: linux/amd64,linux/arm64
5768
push: true
58-
tags: |
59-
ghcr.io/javabin/cupcake:${{ github.sha }}
60-
ghcr.io/javabin/cupcake:latest
61-
labels: |
62-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max
6373

6474
- name: Create staging
6575
if: github.ref == 'refs/heads/main'

.github/workflows/frontend.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,27 @@ jobs:
3636
username: ${{ github.actor }}
3737
password: ${{ github.token }}
3838

39+
- name: Docker metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ghcr.io/javabin/frosting
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=tag
47+
type=sha,format=short
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
3950
- name: Build and push
4051
uses: docker/build-push-action@v6
4152
with:
42-
context: ./frontend
53+
context: .
4354
platforms: linux/amd64,linux/arm64
4455
push: true
45-
tags: |
46-
ghcr.io/javabin/frosting:${{ github.sha }}
47-
ghcr.io/javabin/frosting:latest
48-
labels: |
49-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
5060

5161
- name: Create staging
5262
if: github.ref == 'refs/heads/main'

0 commit comments

Comments
 (0)