Skip to content

Commit 808f33f

Browse files
committed
♻️ refactor: updated CI notify #8
1 parent 606c8a1 commit 808f33f

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

.github/workflows/ci_notify.yml

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Notify
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
tags:
7+
- "v*"
8+
pull_request:
9+
branches: ["master"]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v3
17+
18+
notify:
19+
runs-on: ubuntu-latest
20+
needs: build
21+
steps:
22+
- name: Check Secrets
23+
id: check
24+
run: |
25+
if [[ -z "${{ secrets.TELEGRAM_CHAT_ID }}" || -z "${{ secrets.TELEGRAM_BOT_TOKEN }}" ]]; then
26+
echo "::set-output name=skip::true"
27+
else
28+
echo "::set-output name=skip::false"
29+
fi
30+
- name: Send Telegram Notification
31+
if: steps.check.outputs.skip == 'false'
32+
uses: appleboy/telegram-action@master
33+
with:
34+
to: ${{ secrets.TELEGRAM_CHAT_ID }}
35+
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
36+
format: markdown
37+
message: |
38+
🚀 CI Commit
39+
🔯 `${{ github.actor }}` created commit:
40+
- message: `${{ github.event.commits[0].message }}`
41+
- hash: `${{ github.sha }}`
42+
- repository: `${{ github.repository }}`
43+
- head: `${{ github.event.head_commit.message }}`
44+
🍀 See changes: `https://github.com/${{ github.repository }}/commit/${{github.sha}}`
45+
46+
deploy:
47+
runs-on: ubuntu-latest
48+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
49+
needs: build
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v3
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Check if tag exists
57+
id: check_tag
58+
run: |
59+
if [ -n "$GITHUB_REF" ]; then
60+
TAG=${GITHUB_REF#refs/tags/}
61+
# echo "::set-output name=tag::$TAG"
62+
echo "TAG=${TAG}" >> $GITHUB_ENV
63+
else
64+
# echo "::set-output name=tag::"
65+
echo "TAG=" >> $GITHUB_ENV
66+
fi
67+
shell: bash
68+
69+
- name: Check Secrets
70+
id: check
71+
run: |
72+
if [[ -z "${{ secrets.TELEGRAM_CHAT_ID }}" || -z "${{ secrets.TELEGRAM_BOT_TOKEN }}" ]]; then
73+
echo "::set-output name=skip::true"
74+
else
75+
echo "::set-output name=skip::false"
76+
fi
77+
78+
- name: Generate Changelog
79+
id: changelog
80+
run: |
81+
# Generate your changelog here and set it as an output variable
82+
CHANGELOG=$(git log --pretty=format:"%h - %s" -n 10)
83+
echo "::set-output name=changelog::$CHANGELOG"
84+
85+
- name: Create GitHub Release
86+
id: create_release
87+
uses: softprops/action-gh-release@v1
88+
with:
89+
tag_name: ${{ env.TAG }}
90+
body: |
91+
:gem: released new version ${{ env.TAG }}
92+
draft: false
93+
prerelease: false
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Send Telegram Notification
98+
if: steps.check.outputs.skip == 'false'
99+
uses: appleboy/telegram-action@master
100+
with:
101+
to: ${{ secrets.TELEGRAM_CHAT_ID }}
102+
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
103+
format: markdown
104+
message: |
105+
🚀 New tag created: **${{ env.TAG }}**
106+
🔯 `${{ github.actor }}` created tag:
107+
- repository: `${{ github.repository }}`
108+
- head: `${{ github.event.head_commit.message }}`
109+
🍀 See changes: `https://github.com/${{ github.repository }}/releases/tag/${{ env.TAG }}`
110+
📜 Changelog:
111+
`${{ steps.changelog.outputs.changelog }}`

0 commit comments

Comments
 (0)