Skip to content

Commit 52308dc

Browse files
committed
Add github actions workflow for build
1 parent be5f389 commit 52308dc

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/workflows/docker.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
release:
10+
types: [published]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
packages: write
18+
19+
jobs:
20+
build_and_push:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
# Prevent a failure in one image from stopping the other builds
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- context: "server"
28+
image: "base-server"
29+
platforms: "linux/amd64,linux/arm64"
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Set up QEMU
36+
uses: docker/[email protected]
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/[email protected]
40+
41+
- name: Login to GitHub Container Registry
42+
uses: docker/login-action@v3
43+
# Skip when PR from a fork
44+
if: ${{ !github.event.pull_request.head.repo.fork }}
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.repository_owner }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Generate docker image tags
51+
id: metadata
52+
uses: docker/metadata-action@v5
53+
with:
54+
flavor: |
55+
# Disable latest tag
56+
latest=false
57+
images: |
58+
name=ghcr.io/${{ github.repository_owner }}/${{matrix.image}}
59+
tags: |
60+
# Tag with branch name
61+
type=ref,event=branch
62+
# Tag with pr-number
63+
type=ref,event=pr
64+
# Tag with git tag on release
65+
type=ref,event=tag
66+
67+
- name: Build and push image
68+
uses: docker/[email protected]
69+
with:
70+
context: ${{ matrix.context }}
71+
platforms: ${{ matrix.platforms }}
72+
# Skip pushing when PR from a fork
73+
push: ${{ !github.event.pull_request.head.repo.fork }}
74+
tags: ${{ steps.metadata.outputs.tags }}
75+
labels: ${{ steps.metadata.outputs.labels }}

0 commit comments

Comments
 (0)