Skip to content

Commit 7eb4495

Browse files
authored
feat(notification): Notify in case of Release failure (SAP#5045)
* Update release-go.yml * fix lint
1 parent a242bca commit 7eb4495

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/release-go.yml

+39
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,42 @@ jobs:
8888
piper-version: master
8989
command: githubPublishRelease
9090
flags: --token ${{ secrets.GITHUB_TOKEN }} --version latest --assetPath ./target/jenkins-library.jar
91+
92+
post:
93+
name: Post Action
94+
runs-on: ubuntu-latest
95+
needs: [build]
96+
if: always()
97+
steps:
98+
# Check status of the worklfow
99+
- uses: martialonline/workflow-status@v4
100+
id: check
101+
102+
# This step expects base64 encoded JSON object as below:
103+
# {
104+
# "smtp_url": "smtp+starttls://user:password@server:port",
105+
# "smtp_mail_from": "[email protected]",
106+
# "smtp_mail_rcpt": "[email protected]",
107+
# }
108+
- name: Decode SMTP secrets and set them in GITHUB_ENV
109+
id: smtp_secrets
110+
if: steps.check.outputs.status == 'failure' || steps.check.outputs.status == 'cancelled'
111+
run: >
112+
echo "${{ secrets.SMTP_CONFIG }}" |
113+
base64 --decode |
114+
jq -r 'to_entries[] | "\(.key)=\(.value)"' |
115+
while read line; do
116+
echo "$line" >> $GITHUB_ENV; echo "::add-mask::${line#*=}";
117+
done
118+
- name: Notify Piper team on failure or cancelled
119+
if: steps.smtp_secrets.conclusion == 'success'
120+
uses: dawidd6/action-send-mail@v3
121+
with:
122+
connection_url: ${{ env.smtp_url }}
123+
subject: Workflow failure in ${{ github.repository }}
124+
priority: high
125+
to: ${{ env.smtp_mail_rcpt }}
126+
from: Piper on GitHub <${{ env.smtp_mail_from }}>
127+
body: |
128+
Workflow '${{ github.workflow }}' has a job with status '${{ steps.check.outputs.status }}'.
129+
Workflow link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 commit comments

Comments
 (0)