Skip to content

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

Ping deployer on production Slack notification (#2059)

Krystle Salazarecae72fd904f
diff --git a/.github/actions/production-frontend-deploy/action.yml b/.github/actions/production-frontend-deploy/action.yml
index 5b17ddd63..4c68b2a5c 100644
--- a/.github/actions/production-frontend-deploy/action.yml
+++ b/.github/actions/production-frontend-deploy/action.yml
@@ -18,13 +18,29 @@ inputs:
required: true
slack-webhook:
required: true
+ gh-slack-username-map:
+ required: true
runs:
using: "composite"
steps:
+ - name: Set the Slack user
+ shell: python
+ env:
+ GH_SLACK_USERNAME_MAP: ${{ inputs.GH_SLACK_USERNAME_MAP }}
+ run: |
+ import json
+ import os
+ mapping = json.loads('${{ env.GH_SLACK_USERNAME_MAP }}')
+ github_user = "${{ github.triggering_actor }}"
+ slack_id = mapping[github_user]
+ with open(os.getenv('GITHUB_ENV'), "a") as env_file:
+ env_file.write(f"SLACK_USER_ID={slack_id}")
+
- name: Notify deployment start
uses: slackapi/[email protected]
+ if: success() || failure()
with:
payload: |
{
@@ -34,7 +50,7 @@ runs:
"type": "section",
"text": {
"type": "mrkdwn",
- "text": ":spinning-cd: A deployment of production-frontend is starting using the `${{ inputs.tag }}` tag."
+ "text": ":spinning-cd: A deployment of production-frontend triggered by <@${{ env.SLACK_USER_ID }}> is starting using the `${{ inputs.tag }}` tag."
}
},
{
@@ -52,6 +68,7 @@ runs:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
+ if: success() || failure()
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
@@ -95,7 +112,7 @@ runs:
"type": "section",
"text": {
"type": "mrkdwn",
- "text": ":tadaco: The deployment of production-frontend using the `${{ inputs.tag }}` tag *succeeded*."
+ "text": ":tadaco: The deployment of production-frontend triggered by <@${{ env.SLACK_USER_ID }}> using the `${{ inputs.tag }}` tag *succeeded*."
}
},
{
@@ -123,7 +140,7 @@ runs:
"type": "section",
"text": {
"type": "mrkdwn",
- "text": ":alert: The deployment of production-frontend using the `${{ inputs.tag }}` tag *failed* :alert:"
+ "text": ":alert: The deployment of production-frontend triggered by <@${{ env.SLACK_USER_ID }}> using the `${{ inputs.tag }}` tag *failed* :alert:"
}
},
{
diff --git a/.github/actions/staging-frontend-deploy/action.yml b/.github/actions/staging-frontend-deploy/action.yml
index 5ebe699fd..cf5b2de47 100644
--- a/.github/actions/staging-frontend-deploy/action.yml
+++ b/.github/actions/staging-frontend-deploy/action.yml
@@ -26,8 +26,17 @@ runs:
steps:
- name: Set the Slack user
- shell: bash
- run: echo "SLACK_USER_ID=${{ inputs.gh-slack-username-map[github.actor] }}" >> "$GITHUB_ENV"
+ shell: python
+ env:
+ GH_SLACK_USERNAME_MAP: ${{ inputs.GH_SLACK_USERNAME_MAP }}
+ run: |
+ import json
+ import os
+ mapping = json.loads('${{ env.GH_SLACK_USERNAME_MAP }}')
+ github_user = "${{ github.triggering_actor }}"
+ slack_id = mapping[github_user]
+ with open(os.getenv('GITHUB_ENV'), "a") as env_file:
+ env_file.write(f"SLACK_USER_ID={slack_id}")
- name: Notify deployment start
uses: slackapi/[email protected]
diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml
index c6026a669..68ea26ace 100644
--- a/.github/workflows/ghcr.yml
+++ b/.github/workflows/ghcr.yml
@@ -118,3 +118,4 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
+ gh-slack-username-map: ${{ secrets.GH_SLACK_USERNAME_MAP }}
diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml
index 6c4a3c555..42b545d74 100644
--- a/.github/workflows/rollback.yml
+++ b/.github/workflows/rollback.yml
@@ -81,6 +81,7 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
+ gh-slack-username-map: ${{ secrets.GH_SLACK_USERNAME_MAP }}
- uses: ./.github/actions/staging-frontend-deploy
if: inputs.environment == 'staging'