Skip to content

Commit 00f5766

Browse files
committed
Add GitHub Actions workflow for building and pushing a Docker image.
1 parent c441e79 commit 00f5766

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Build and Push Docker Image
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- ci/docker-build
9+
tags:
10+
- '*'
11+
pull_request:
12+
branches:
13+
- main
14+
# Allow manually triggering the workflow.
15+
workflow_dispatch:
16+
17+
# Cancels all previous workflow runs for the same branch that have not yet completed.
18+
concurrency:
19+
# The concurrency group contains the workflow name and the branch name.
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build-and-push-image:
25+
permissions:
26+
contents: read
27+
packages: write
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Create docker tag (from git reference)
31+
# A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes.
32+
run: |
33+
echo "TAG=$(echo -n "${{ github.ref_name }}" \
34+
| tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \
35+
>> "${GITHUB_ENV}"
36+
- name: Checkout Repository
37+
uses: actions/checkout@v6
38+
- name: Log in to GitHub Container Registry
39+
uses: docker/login-action@v4
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
- name: Set up Docker QEMU
45+
uses: docker/setup-qemu-action@v4
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v4
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@v4
50+
with:
51+
context: .
52+
platforms: linux/amd64,linux/arm64
53+
push: true
54+
tags: "ghcr.io/${{ github.repository }}:${{ env.TAG }}"

0 commit comments

Comments
 (0)