Skip to content

Commit 89f41d1

Browse files
authored
Add container build workflow (#9)
Container is built on every PR and published on all tags matching `v*`
1 parent a65ab14 commit 89f41d1

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Image Checks
2+
3+
on:
4+
push:
5+
# Run only on release tags
6+
tags:
7+
- v*
8+
# or commits to main (when PRs are merged)
9+
branches:
10+
- main
11+
# but all PRs
12+
pull_request:
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Generate Metadata
25+
id: meta
26+
uses: docker/metadata-action@v5
27+
with:
28+
images: ghcr.io/${{ github.repository }}
29+
tags: |
30+
type=semver,pattern={{version}}
31+
32+
- name: Build image
33+
uses: docker/build-push-action@v6
34+
env:
35+
DOCKER_BUILD_RECORD_UPLOAD: false
36+
with:
37+
context: .
38+
cache-from: type=gha
39+
cache-to: type=gha
40+
tags: ${{ steps.meta.outputs.tags }}
41+
load: true
42+
43+
- name: Login to GHCR
44+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io/${{ github.repository_owner }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Publish image
52+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
53+
uses: docker/build-push-action@v6
54+
env:
55+
DOCKER_BUILD_RECORD_UPLOAD: false
56+
with:
57+
context: .
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
annotations: ${{ steps.meta.outputs.annotations }}
61+
push: true

0 commit comments

Comments
 (0)