diff --git a/.github/workflows/deploy-cloud.yaml b/.github/workflows/deploy-cloud.yaml index 6b95b9b3a..7e45aa69a 100644 --- a/.github/workflows/deploy-cloud.yaml +++ b/.github/workflows/deploy-cloud.yaml @@ -66,6 +66,7 @@ jobs: JOB_DEPLOYMENT_KIND: production JOB_STATUS: ${{ job.status }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} + SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" run: | python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-demo-staging.yaml b/.github/workflows/deploy-demo-staging.yaml index 076bbf260..ce9ed575a 100644 --- a/.github/workflows/deploy-demo-staging.yaml +++ b/.github/workflows/deploy-demo-staging.yaml @@ -81,6 +81,7 @@ jobs: JOB_DEPLOYMENT_KIND: production JOB_STATUS: ${{ job.status }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} + SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" run: | python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-demo.yaml b/.github/workflows/deploy-demo.yaml index dd2369289..3e0d256fa 100644 --- a/.github/workflows/deploy-demo.yaml +++ b/.github/workflows/deploy-demo.yaml @@ -50,6 +50,7 @@ jobs: JOB_DEPLOYMENT_KIND: production JOB_STATUS: ${{ job.status }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} + SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" run: | python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-gcp.yml b/.github/workflows/deploy-gcp.yml index 4d5ecd5cf..194e11a1f 100644 --- a/.github/workflows/deploy-gcp.yml +++ b/.github/workflows/deploy-gcp.yml @@ -55,6 +55,7 @@ jobs: JOB_DEPLOYMENT_KIND: production JOB_STATUS: ${{ job.status }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} + SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" run: | python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-master-staging.yaml b/.github/workflows/deploy-master-staging.yaml index 9f6c0f69f..5c179378a 100644 --- a/.github/workflows/deploy-master-staging.yaml +++ b/.github/workflows/deploy-master-staging.yaml @@ -59,6 +59,7 @@ jobs: JOB_DEPLOYMENT_KIND: staging JOB_STATUS: ${{ job.status }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} + SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} JOB_TITLE: "Dashboard deployment to saleor-master-staging" run: | python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 4cfbf0496..6417c0d35 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -85,6 +85,7 @@ jobs: JOB_DEPLOYMENT_KIND: staging JOB_STATUS: ${{ job.status }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} + SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" run: | python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/notify/notify-slack.py b/.github/workflows/notify/notify-slack.py index 97f76b606..61e8d948f 100755 --- a/.github/workflows/notify/notify-slack.py +++ b/.github/workflows/notify/notify-slack.py @@ -46,6 +46,9 @@ class JobNotifier: # Development notifier configuration is available at: https://api.slack.com/apps/A0210C30YLD/ self.slack_endpoint = os.environ["SLACK_WEBHOOK_URL"] + # ID of Slack Group to mention in case of failure + self.slack_mention_group_id = os.getenv("SLACK_MENTION_GROUP_ID", default="") + # Workflow Run ID to retrieve the logs permalink of the actual run (failed/succeeded) self.run_id: str = os.environ["GITHUB_RUN_ID"] @@ -73,10 +76,11 @@ class JobNotifier: def make_slack_message(self) -> dict: status = self.job_status.capitalize() + mention = self.slack_mention_group_id if status == "Failure" else "" # Dev deployment triggered by JohnDoe: Success text = ( f"{self.author} {self.job_kind} finished for '{self.deployment_kind.capitalize()}', result: " - f"{status}" + f"{status} {mention}" ) message_data = { "attachments": [