Skip to content

Commit 567c93a

Browse files
Merge pull request #19337 from simonszu/feat/docker-build
feat: Github Action for Docker build
2 parents 3f6c4ca + d9f3025 commit 567c93a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build and Push Docker Image on Tag
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Log in to GitHub Container Registry
17+
uses: docker/login-action@v2
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.repository_owner }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Extract tag name
24+
id: vars
25+
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
26+
27+
- name: Build Docker image
28+
run: |
29+
docker build -f docker/Dockerfile -t ghcr.io/${{ github.repository_owner }}/maltrail:${{ env.TAG }} .
30+
31+
- name: Push Docker image
32+
run: |
33+
docker push ghcr.io/${{ github.repository_owner }}/maltrail:${{ env.TAG }}
34+
35+
- name: Optional: Also tag latest
36+
run: |
37+
docker tag ghcr.io/${{ github.repository_owner }}/maltrail:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/maltrail:latest
38+
docker push ghcr.io/${{ github.repository_owner }}/maltrail:latest

0 commit comments

Comments
 (0)