Add notification if release job fails (#3080)

* add notification if release job fails

* Update .github/workflows/tests-nightly.yml

Co-authored-by: Mika <6186720+NyanKiyoshi@users.noreply.github.com>

---------

Co-authored-by: Mika <6186720+NyanKiyoshi@users.noreply.github.com>
This commit is contained in:
Karolina Rakoczy 2023-02-02 10:40:28 +01:00 committed by GitHub
parent e4db92be74
commit 2958ab2ac5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -14,6 +14,7 @@ Manual Environment Variables (explicit):
- SLACK_WEBHOOK_URL: incoming webhook URL to send payload/message to - SLACK_WEBHOOK_URL: incoming webhook URL to send payload/message to
- JOB_STATUS: status from GitHub's ``job.status`` - JOB_STATUS: status from GitHub's ``job.status``
- JOB_TITLE: the title of the job - JOB_TITLE: the title of the job
- JOB_KIND: kind of job to notify about, by default "deployment"
Global GitHub Environment Variables (implicit): Global GitHub Environment Variables (implicit):
- GITHUB_RUN_ID - GITHUB_RUN_ID
@ -57,6 +58,9 @@ class JobNotifier:
# Job Status (success|failure|cancelled) # Job Status (success|failure|cancelled)
self.job_status: str = os.environ["JOB_STATUS"] self.job_status: str = os.environ["JOB_STATUS"]
# The kind of job (deployment, release tests, ...)
self.job_kind: str = os.getenv("JOB_KIND", "deployment")
@property @property
def run_permalink(self) -> str: def run_permalink(self) -> str:
"""Permalink to the current run logs""" """Permalink to the current run logs"""
@ -71,7 +75,7 @@ class JobNotifier:
status = self.job_status.capitalize() status = self.job_status.capitalize()
# Dev deployment triggered by JohnDoe: Success # Dev deployment triggered by JohnDoe: Success
text = ( text = (
f"{self.author} deployment finished for '{self.deployment_kind.capitalize()}', result: " f"{self.author} {self.job_kind} finished for '{self.deployment_kind.capitalize()}', result: "
f"{status}" f"{status}"
) )
message_data = { message_data = {

View file

@ -286,3 +286,14 @@ jobs:
--pull_request_number $pull_request_number \ --pull_request_number $pull_request_number \
--dashboard_url $dashboard_url \ --dashboard_url $dashboard_url \
$auto_release $auto_release
- name: Notify Slack
if: ${{ failure() && github.event_name == 'repository_dispatch'}}
env:
JOB_DEPLOYMENT_KIND: staging
JOB_STATUS: ${{ job.status }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASES_WEBHOOK_URL }}
JOB_TITLE: "Test release workflow - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}"
JOB_KIND: "release tests"
run: |
python3 ./.github/workflows/notify/notify-slack.py