Skip to content

Commit

Permalink
Merge pull request #28 from sima-land/25-notify
Browse files Browse the repository at this point in the history
#25 Добавить оповещения в TG
  • Loading branch information
krutoo committed Oct 11, 2023
2 parents aae4f4d + 2e1a3a1 commit 375e590
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/actions/publish-notify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Publish notify'
description: 'Log publish workflow to Telegram'
author: 'sima-land team'

inputs:
stage:
required: true
description: 'Stage: "start", "done" or "fail"'
tg-bot-token:
required: true
description: 'Telegram bot token'
tg-chat-id:
required: true
description: 'Telegram chat id'

runs:
using: 'composite'
steps:
- name: Define package name
if: ${{ success() && inputs.stage == 'start' }}
shell: bash
run: cat package.json | jq '.name' | awk '{print "package_name=" $0}' >> $GITHUB_ENV

- name: Publish START message
if: ${{ success() && inputs.stage == 'start' }}
uses: appleboy/telegram-action@master
with:
token: ${{ inputs.tg-bot-token }}
to: ${{ inputs.tg-chat-id }}
message: |
▶️ Запущена публикация пакета ${{ env.package_name }}
- name: Publish DONE message
if: ${{ success() && inputs.stage == 'done' }}
uses: appleboy/telegram-action@master
with:
token: ${{ inputs.tg-bot-token }}
to: ${{ inputs.tg-chat-id }}
message: |
✅ Опубликована версия ${{ github.ref_name }} пакета ${{ env.package_name }}
Описание релиза: ${{ github.event.release.html_url }}
- name: Publish FAIL message
if: ${{ failure() || inputs.stage == 'fail' }}
uses: appleboy/telegram-action@master
with:
token: ${{ inputs.tg-bot-token }}
to: ${{ inputs.tg-chat-id }}
message: |
🆘 Не удалось опубликовать пакет ${{ env.package_name }}
Детали: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
20 changes: 20 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
node-version: 16
registry-url: https://registry.npmjs.org/

- uses: ./.github/actions/publish-notify
with:
stage: start
tg-bot-token: ${{ secrets.TG_BOT_TOKEN }}
tg-chat-id: ${{ secrets.TG_CHAT_ID }}

- name: Install dependencies
run: npm ci

Expand All @@ -22,3 +28,17 @@ jobs:
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

- uses: ./.github/actions/publish-notify
if: success()
with:
stage: done
tg-bot-token: ${{ secrets.TG_BOT_TOKEN }}
tg-chat-id: ${{ secrets.TG_CHAT_ID }}

- uses: ./.github/actions/publish-notify
if: failure()
with:
stage: fail
tg-bot-token: ${{ secrets.TG_BOT_TOKEN }}
tg-chat-id: ${{ secrets.TG_CHAT_ID }}

0 comments on commit 375e590

Please sign in to comment.