Skip to content

Commit 31bd737

Browse files
committed
Add CICD for Container Build
1 parent 08cca9b commit 31bd737

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.github/workflows/cicd.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build:
14+
name: Build and Push Docker Image to Hub
15+
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Log in to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{ secrets.DOCKER_USERNAME }}
25+
password: ${{ secrets.DOCKER_TOKEN }}
26+
27+
- name: Build and push Docker image
28+
uses: docker/build-push-action@v6
29+
with:
30+
push: true
31+
tags: ${{ secrets.DOCKER_USERNAME }}/printserver:${{ github.sha }}
32+
33+
release:
34+
name: Create GitHub Release
35+
needs: build
36+
37+
runs-on: ubuntu-latest
38+
39+
permissions:
40+
contents: write
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Get Version
46+
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
47+
48+
- name: Delete existing release if it exists
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
run: |
52+
gh release delete ${{ env.VERSION }} -y || echo "Release does not exist, continuing..."
53+
54+
- name: Create GitHub Release
55+
id: create_release
56+
env:
57+
GH_TOKEN: ${{ github.token }}
58+
run: |
59+
RELEASE_NOTES="Docker Hub: https://hub.docker.com/r/${{ secrets.DOCKER_USERNAME }}/printserver"
60+
gh release create ${{ env.VERSION }} --title "Brother Label Print Server - v${{ env.VERSION }}" --notes "$RELEASE_NOTES" --generate-notes

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2

0 commit comments

Comments
 (0)