From 2cb610d3ff689ca1cbf5c0494e2b8125275c8b62 Mon Sep 17 00:00:00 2001 From: Googlom <36107508+Googlom@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:02:24 +0500 Subject: [PATCH] feat(notification): Notify in case of Release failure (#218) * implement post stage * test * fix param * remove test exit * add comment * fix lint --------- Co-authored-by: Gulom Alimov --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cb99676f..f249e49b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,3 +59,43 @@ jobs: tag_name: ${{ steps.version.outputs.v-version }} generate_release_notes: true make_latest: true + + post: + name: Post Action + runs-on: ubuntu-latest + needs: [release] + if: always() + steps: + # Check status of the worklfow + - uses: martialonline/workflow-status@v4 + id: check + + # This step expects base64 encoded JSON object as below: + # { + # "smtp_url": "smtp+starttls://user:password@server:port", + # "smtp_mail_from": "from@mail.example", + # "smtp_mail_rcpt": "to@mail.example", + # } + - name: Decode SMTP secrets and set them in GITHUB_ENV + id: smtp_secrets + if: steps.check.outputs.status == 'failure' || steps.check.outputs.status == 'cancelled' + run: > + echo "${{ secrets.SMTP_CONFIG }}" | + base64 --decode | + jq -r 'to_entries[] | "\(.key)=\(.value)"' | + while read line; do + echo "$line" >> $GITHUB_ENV; echo "::add-mask::${line#*=}"; + done + + - name: Notify Piper team on failure or cancelled + if: steps.smtp_secrets.conclusion == 'success' + uses: dawidd6/action-send-mail@v3 + with: + connection_url: ${{ env.smtp_url }} + subject: Workflow failure in ${{ github.repository }} + priority: high + to: ${{ env.smtp_mail_rcpt }} + from: Piper on GitHub <${{ env.smtp_mail_from }}> + body: | + Workflow '${{ github.workflow }}' has a job with status '${{ steps.check.outputs.status }}'. + Workflow link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}