From 2e1a3a1a0e85e1ebba648789019d7a02d4d3991a Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 11 Oct 2023 11:27:08 +0500 Subject: [PATCH] #25 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - добавлены оповещения о стадиях публикации в tg --- .github/actions/publish-notify/action.yml | 53 +++++++++++++++++++++++ .github/workflows/npm-publish.yml | 20 +++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/actions/publish-notify/action.yml diff --git a/.github/actions/publish-notify/action.yml b/.github/actions/publish-notify/action.yml new file mode 100644 index 0000000..0fe5048 --- /dev/null +++ b/.github/actions/publish-notify/action.yml @@ -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 }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index ceca8e6..ca2402c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -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 @@ -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 }}