Skip to content

Commit 6a2955e

Browse files
committed
ci: publish app images to ghcr on push
1 parent a3c2221 commit 6a2955e

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
strategy:
16+
matrix:
17+
include:
18+
- image: compose-api
19+
context: 04-compose/app
20+
- image: blazor-chat
21+
context: 05-blazor-chat
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to GitHub Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract metadata
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: ghcr.io/${{ github.repository }}/${{ matrix.image }}
39+
tags: |
40+
type=raw,value=latest,enable={{is_default_branch}}
41+
type=sha,format=short
42+
type=semver,pattern={{version}}
43+
44+
- name: Build and push
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: ${{ matrix.context }}
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)