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:
parent
e4db92be74
commit
2958ab2ac5
2 changed files with 16 additions and 1 deletions
6
.github/workflows/notify/notify-slack.py
vendored
6
.github/workflows/notify/notify-slack.py
vendored
|
@ -14,6 +14,7 @@ Manual Environment Variables (explicit):
|
|||
- SLACK_WEBHOOK_URL: incoming webhook URL to send payload/message to
|
||||
- JOB_STATUS: status from GitHub's ``job.status``
|
||||
- JOB_TITLE: the title of the job
|
||||
- JOB_KIND: kind of job to notify about, by default "deployment"
|
||||
|
||||
Global GitHub Environment Variables (implicit):
|
||||
- GITHUB_RUN_ID
|
||||
|
@ -57,6 +58,9 @@ class JobNotifier:
|
|||
# Job Status (success|failure|cancelled)
|
||||
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
|
||||
def run_permalink(self) -> str:
|
||||
"""Permalink to the current run logs"""
|
||||
|
@ -71,7 +75,7 @@ class JobNotifier:
|
|||
status = self.job_status.capitalize()
|
||||
# Dev deployment triggered by JohnDoe: Success
|
||||
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}"
|
||||
)
|
||||
message_data = {
|
||||
|
|
11
.github/workflows/tests-nightly.yml
vendored
11
.github/workflows/tests-nightly.yml
vendored
|
@ -286,3 +286,14 @@ jobs:
|
|||
--pull_request_number $pull_request_number \
|
||||
--dashboard_url $dashboard_url \
|
||||
$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
|
Loading…
Reference in a new issue