Skip to content

Commit 2a1ee70

Browse files
author
BoxBoxJason
committed
ci: add deployment workflow on tags
1 parent a86daef commit 2a1ee70

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: build-image
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up version variables
16+
id: vars
17+
run: |
18+
VERSION=${{ github.ref_name }}
19+
MAJOR=$(echo $VERSION | cut -d. -f1)
20+
MINOR=$(echo $VERSION | cut -d. -f2)
21+
REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
22+
echo "VERSION=$VERSION" >> $GITHUB_ENV
23+
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
24+
echo "MINOR=$MINOR" >> $GITHUB_ENV
25+
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
26+
27+
- name: Log in to GHCR
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Build and push Docker image
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: .
41+
file: Containerfile
42+
push: true
43+
sbom: true
44+
build-args: |
45+
GITLAB_SYNC_VERSION=${{ github.ref_name }}
46+
tags: |
47+
ghcr.io/${{ env.REPO_NAME }}:${{ github.ref_name }}
48+
ghcr.io/${{ env.REPO_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }}
49+
ghcr.io/${{ env.REPO_NAME }}:${{ env.MAJOR }}
50+
ghcr.io/${{ env.REPO_NAME }}:latest

0 commit comments

Comments
 (0)