-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0dfb64
commit ce1d3e0
Showing
1 changed file
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: Notify | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: ["master"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
notify: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Check Secrets | ||
id: check | ||
run: | | ||
if [[ -z "${{ secrets.TELEGRAM_CHAT_ID }}" || -z "${{ secrets.TELEGRAM_BOT_TOKEN }}" ]]; then | ||
echo "::set-output name=skip::true" | ||
else | ||
echo "::set-output name=skip::false" | ||
fi | ||
- name: Send Telegram Notification | ||
if: steps.check.outputs.skip == 'false' | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_CHAT_ID }} | ||
token: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
format: markdown | ||
message: | | ||
🚀 CI Commit | ||
🔯 `${{ github.actor }}` created commit: | ||
- message: `${{ github.event.commits[0].message }}` | ||
- hash: `${{ github.sha }}` | ||
- repository: `${{ github.repository }}` | ||
- head: `${{ github.event.head_commit.message }}` | ||
🍀 See changes: `https://github.com/${{ github.repository }}/commit/${{github.sha}}` | ||
deploy: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
needs: build | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check if tag exists | ||
id: check_tag | ||
run: | | ||
if [ -n "$GITHUB_REF" ]; then | ||
TAG=${GITHUB_REF#refs/tags/} | ||
# echo "::set-output name=tag::$TAG" | ||
echo "TAG=${TAG}" >> $GITHUB_ENV | ||
else | ||
# echo "::set-output name=tag::" | ||
echo "TAG=" >> $GITHUB_ENV | ||
fi | ||
shell: bash | ||
|
||
- name: Check Secrets | ||
id: check | ||
run: | | ||
if [[ -z "${{ secrets.TELEGRAM_CHAT_ID }}" || -z "${{ secrets.TELEGRAM_BOT_TOKEN }}" ]]; then | ||
echo "::set-output name=skip::true" | ||
else | ||
echo "::set-output name=skip::false" | ||
fi | ||
- name: Generate Changelog | ||
id: changelog | ||
run: | | ||
# Generate your changelog here and set it as an output variable | ||
CHANGELOG=$(git log --pretty=format:"%h - %s" -n 10) | ||
echo "::set-output name=changelog::$CHANGELOG" | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ env.TAG }} | ||
body: | | ||
:gem: released new version ${{ env.TAG }} | ||
draft: false | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Send Telegram Notification | ||
if: steps.check.outputs.skip == 'false' | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_CHAT_ID }} | ||
token: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
format: markdown | ||
message: | | ||
🚀 New tag created: **${{ env.TAG }}** | ||
🔯 `${{ github.actor }}` created tag: | ||
- repository: `${{ github.repository }}` | ||
- head: `${{ github.event.head_commit.message }}` | ||
🍀 See changes: `https://github.com/${{ github.repository }}/releases/tag/${{ env.TAG }}` | ||
📜 Changelog: | ||
`${{ steps.changelog.outputs.changelog }}` |