Skip to content

Commit 93c17a8

Browse files
committed
Add Docker image build workflow
1 parent 2782dec commit 93c17a8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/build-image.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build Docker image
2+
3+
on:
4+
push:
5+
branches: ["development"]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
env:
11+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
runs-on: ubuntu-24.04
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
23+
steps:
24+
- name: Branch safety check
25+
run: '[ "${{ env.BRANCH_NAME }}" = "development" ] || [ "${{ env.BRANCH_NAME }}" = "stable" ]'
26+
27+
- id: lowercase_image_name
28+
run: echo "IMAGE_NAME_LC=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_OUTPUT}
29+
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Log in to the Container registry
34+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Build and push Docker image
41+
id: push
42+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
43+
with:
44+
context: .
45+
file: ./Dockerfile
46+
push: true
47+
tags: ${{ env.REGISTRY }}/${{ steps.lowercase_image_name.outputs.IMAGE_NAME_LC }}:${{ env.BRANCH_NAME }}

0 commit comments

Comments
 (0)