Skip to content

Commit 2bf4cf0

Browse files
committed
Add support for automated GitHub releases on tag push
1 parent 77148f1 commit 2bf4cf0

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

.github/workflows/docker-build.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Docker Build and Push
22

33
on:
44
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
59
paths:
610
- 'src/**'
711
- '.dockerignore'
@@ -11,19 +15,17 @@ on:
1115
- 'Dockerfile'
1216
- 'package.json'
1317
- 'package-lock.json'
14-
branches:
15-
- main
1618

1719
jobs:
1820
build-and-push:
21+
if: github.ref == 'refs/heads/main'
1922
runs-on: ubuntu-latest
2023
steps:
2124
- name: Checkout code
2225
uses: actions/checkout@v4
2326

2427
- name: Set up Node.js
2528
uses: actions/setup-node@v4
26-
2729
with:
2830
node-version: 22
2931
cache: 'npm'
@@ -57,3 +59,30 @@ jobs:
5759
tags: xcrypt0r/watchdog:latest
5860
cache-from: type=gha
5961
cache-to: type=gha,mode=max
62+
63+
update-release:
64+
if: startsWith(github.ref, 'refs/tags/')
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
70+
- name: Strip "v" from tag
71+
id: strip
72+
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
73+
74+
- name: Update GitHub Release
75+
uses: softprops/action-gh-release@v1
76+
with:
77+
tag_name: ${{ github.ref_name }}
78+
name: Watchdog ${{ steps.strip.outputs.version }}
79+
body: |
80+
🐳 Docker image pushed
81+
82+
```
83+
docker pull xcrypt0r/watchdog:latest
84+
```
85+
86+
[View on Docker Hub](https://hub.docker.com/r/xcrypt0r/watchdog)
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)