Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Updates to CI CD notifications (#2404)

Zack Krida524b67801ba8
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 7f5eb7457..4b439ab88 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -995,17 +995,28 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
+ - name: Get commit message
+ id: commit
+ env:
+ COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
+ PYTHONPATH: ${{ github.workspace }}/automations/python
+ working-directory: automations/python/workflows
+ run: python get_commit_message.py
+
- name: Generate report
id: report
env:
+ COMMIT_MESSAGE: ${{ steps.commit.outputs.commit_message }}
+ DEPLOY_API_RESULT: ${{ needs.deploy-api.result }}
+ DEPLOY_FRONTEND_RESULT: ${{ needs.deploy-frontend.result }}
EMIT_DOCS_RESULT: ${{ needs.emit-docs.result }}
+ GH_SLACK_USERNAME_MAP: ${{ secrets.GH_SLACK_USERNAME_MAP }}
+ GITHUB_ACTOR: ${{ github.event.head_commit.author.username }}
PUBLISH_IMAGES_RESULT: ${{ needs.publish-images.result }}
- DEPLOY_FRONTEND_RESULT: ${{ needs.deploy-frontend.result }}
- DEPLOY_API_RESULT: ${{ needs.deploy-api.result }}
- SERVER_URL: ${{ github.server_url }}
+ PYTHONPATH: ${{ github.workspace }}/automations/python
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
- PYTHONPATH: ${{ github.workspace }}/automations/python
+ SERVER_URL: ${{ github.server_url }}
working-directory: automations/python/workflows
run: python generate_report.py
diff --git a/automations/python/workflows/generate_report.py b/automations/python/workflows/generate_report.py
index b5cafef49..9d717f65d 100644
--- a/automations/python/workflows/generate_report.py
+++ b/automations/python/workflows/generate_report.py
@@ -10,6 +10,14 @@ from shared.actions import write_to_github_output
server_url = os.environ.get("SERVER_URL")
repository = os.environ.get("REPOSITORY")
run_id = os.environ.get("RUN_ID")
+gh_slack_username_map = json.loads(os.environ.get("GH_SLACK_USERNAME_MAP", "{}"))
+github_username = os.environ.get(
+ "GITHUB_ACTOR"
+) # GitHub username of the actor that initiated the current workflow
+commit_message = os.environ.get("COMMIT_MESSAGE")
+commit_url = f"{server_url}/{repository}/commit/{os.environ.get('GITHUB_SHA')}"
+
+slack_id = gh_slack_username_map.get(github_username)
jobs = ["emit-docs", "publish-images", "deploy-frontend", "deploy-api"]
@@ -21,6 +29,8 @@ for job_name in jobs:
results[job_name] = result
counts[result] += 1
+user_mention = f"<@{slack_id}>" if slack_id else github_username
+
payload = {
"text": ", ".join(f"{count} {result}" for result, count in counts.items()),
"blocks": [
@@ -29,8 +39,9 @@ payload = {
"text": {
"type": "mrkdwn",
"text": (
- f"<{server_url}/{repository}/actions/runs/{run_id}|"
- "Click here to review the completed CI + CD workflow>."
+ f"Hi {user_mention}, some CI + CD checks failed for your merge of <{commit_url}|{commit_message}>.\n" # noqa: E501
+ "This _could_ indicate problems with deployments or tests introduced by your PR.\n" # noqa: E501
+ "Please reply to this message with :ack: when seen, :github-approved: when resolved, or :issue_created: if it is unresolved and needs work. Link to any relevant issues you create.\n" # noqa: E501
),
},
},
@@ -44,6 +55,20 @@ payload = {
for job_name, result in results.items()
],
},
+ {
+ "type": "actions",
+ "elements": [
+ {
+ "type": "button",
+ "text": {
+ "type": "plain_text",
+ "text": "Review CI + CD Workflow",
+ },
+ "url": f"{server_url}/{repository}/actions/runs/{run_id}",
+ "style": "primary",
+ }
+ ],
+ },
],
}