Skip to content

Commit af0a0b7

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

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
22+
echo "MINOR=$MINOR" >> $GITHUB_ENV
23+
24+
- name: Log in to GHCR
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Build and push Docker image
35+
uses: docker/build-push-action@v6
36+
with:
37+
context: .
38+
file: Containerfile
39+
push: true
40+
sbom: true
41+
build-args: |
42+
GITLAB_SYNC_VERSION=${{ github.ref_name }}
43+
tags: |
44+
ghcr.io/${{ github.repository }}:${{ github.ref_name}}
45+
ghcr.io/${{ github.repository }}:${{ env.MAJOR }}.${{ env.MINOR }}
46+
ghcr.io/${{ github.repository }}:latest

0 commit comments

Comments
 (0)