diff --git a/.github/resources/slack-payloads/slack-message-template.json b/.github/resources/slack-payloads/slack-message-template.json new file mode 100644 index 00000000..ea175a3f --- /dev/null +++ b/.github/resources/slack-payloads/slack-message-template.json @@ -0,0 +1,22 @@ +{ + "attachments": [ + { + "pretext": "{{ env.PRE_TEXT_MESSAGE }}", + "fallback": "{{ env.FALLBACK_MESSAGE }}", + "color": "{{ env.COLOR }}", + "author_name": "{{ github.workflow }}", + "author_link": "{{ env.GITHUB_SERVER_URL }}/{{ env.GITHUB_REPOSITORY }}/actions/runs/{{ env.GITHUB_RUN_ID }}", + "title": "{{ env.GITHUB_REPOSITORY }}", + "title_link": "{{ env.GITHUB_SERVER_URL }}/{{ env.GITHUB_REPOSITORY }}", + "fields": [ + { + "title": "Release Tag", + "short": true, + "value": "{{ env.RELEASETAG }}" + } + ], + "footer": "deployed by: {{ github.actor }}", + "footer_icon": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" + } + ] +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 235bbe88..d38d91ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,3 +68,39 @@ jobs: uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.PYPI_TOKEN }} + + post-release: + name: Post Release Actions + + runs-on: ubuntu-latest + if: ${{ always() }} + needs: + - generate-version + - publish + + steps: + - name: Slack - Success Message + uses: DSdatsme/slack-github-action@env_support + if: ${{ success() && needs.publish.result == 'success' }} + with: + channel-id: ${{ vars.SLACK_CHANNEL_ID }} + payload-file-path: ./.github/resources/slack-payloads/slack-message-template.json + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + RELEASETAG: ${{ needs.generate-version.outputs.new_version }} + PRE_TEXT_MESSAGE: "Workflow Passed! :successkid:" + FALLBACK_MESSAGE: "Workflow Passed!" + COLOR: "good" + + - name: Slack - Failure Message + uses: DSdatsme/slack-github-action@env_support + if: ${{ failure() || needs.publish.result != 'success' }} + with: + channel-id: ${{ vars.SLACK_CHANNEL_ID }} + payload-file-path: ./.github/resources/slack-payloads/slack-message-template.json + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + RELEASETAG: ${{ needs.generate-version.outputs.new_version }} + PRE_TEXT_MESSAGE: " Workflow Failed! :x:" + FALLBACK_MESSAGE: "Workflow Failed!" + COLOR: "danger"