Skip to content

Commit ac21ce5

Browse files
github/workflows: adds automated image building (#370)
* github/workflow: add ghcr build-push workflow * github/workflow: add build caching and push * github/workflows: add registry prefix * github/workflows: add build-concurrency groups w/ termination
1 parent e5df179 commit ac21ce5

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/build-and-push.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Push
2+
3+
on: push
4+
5+
env:
6+
registry: ghcr.io
7+
image-name: ${{ github.repository }}
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v2
23+
24+
- name: Determine tags
25+
id: metadata
26+
uses: docker/metadata-action@v4
27+
with:
28+
images: ${{ env.registry }}/${{ env.image-name }}
29+
tags: |
30+
type=sha,prefix=,format=long
31+
type=schedule
32+
type=ref,event=branch
33+
type=ref,event=pr
34+
type=raw,value=latest,enable={{ is_default_branch }}
35+
36+
- name: Log in to the Container registry
37+
uses: docker/login-action@v2.1.0
38+
with:
39+
registry: ${{ env.registry }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Build and push ${{ env.image-name }}
44+
uses: docker/build-push-action@v3
45+
with:
46+
push: true
47+
tags: ${{ steps.metadata.outputs.tags }}
48+
labels: ${{ steps.metadata.outputs.labels }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
52+
concurrency:
53+
group: ${{ github.ref }}
54+
cancel-in-progress: true

0 commit comments

Comments
 (0)