From d01f2b6642c1b825f3a18c122ecf15b4e1f28984 Mon Sep 17 00:00:00 2001 From: Qi Date: Wed, 8 Jan 2025 16:11:40 +0800 Subject: [PATCH] chore(CI): remove `release-and-tests-fail-bot.yml` --- .../workflows/release-and-tests-fail-bot.yml | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 .github/workflows/release-and-tests-fail-bot.yml diff --git a/.github/workflows/release-and-tests-fail-bot.yml b/.github/workflows/release-and-tests-fail-bot.yml deleted file mode 100644 index 8b12ca3f2ab6..000000000000 --- a/.github/workflows/release-and-tests-fail-bot.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Notify Slack user on workflow failure - -on: - workflow_run: - workflows: ["Package & Release", "Build & Test"] - types: - - completed - branches: - - master - - release/* - - next/* - -jobs: - notify_failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event != 'schedule' }} - steps: - - name: Fetch mapping file - id: fetch_mapping - uses: actions/github-script@v7 - env: - ACCESS_TOKEN: ${{ secrets.PAT }} - with: - script: | - const url = 'https://raw.githubusercontent.com/Kong/github-slack-mapping/main/mapping.json'; - const headers = {Authorization: `token ${process.env.ACCESS_TOKEN}`}; - const response = await fetch(url, {headers}); - const mapping = await response.json(); - return mapping; - - - name: Retrieve PR info - id: retrieve_pr_info - env: - ACCESS_TOKEN: ${{ secrets.PAT }} - run: | - repo_name="${{ github.event.workflow_run.repository.full_name }}" - head_sha="${{ github.event.workflow_run.head_sha }}" - IFS=$'\t' read pr_html_url pr_user_login < <(curl -sS \ - -H "Authorization: Bearer ${{ env.ACCESS_TOKEN }}" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/$repo_name/commits/$head_sha/pulls" \ - | jq -r '.[0] | [.html_url, .user.login] | @tsv') - echo "pr_html_url=$pr_html_url" >> $GITHUB_OUTPUT - echo "pr_user_login=$pr_user_login" >> $GITHUB_OUTPUT - shell: bash - - - name: Generate Slack Payload - id: generate-payload - env: - SLACK_CHANNEL: gateway-notifications - SLACK_MAPPING: "${{ steps.fetch_mapping.outputs.result }}" - uses: actions/github-script@v7 - with: - script: | - const pr_html_url = "${{ steps.retrieve_pr_info.outputs.pr_html_url }}"; - const workflow_name = "${{ github.event.workflow_run.name }}"; - const repo_name = "${{ github.event.workflow_run.repository.full_name }}"; - const branch_name = "${{ github.event.workflow_run.head_branch }}"; - const run_url = "${{ github.event.workflow_run.html_url }}"; - const slack_mapping = JSON.parse(process.env.SLACK_MAPPING); - const actor_github_id = "${{ steps.retrieve_pr_info.outputs.pr_user_login }}"; - const actor_slack_id = slack_mapping[actor_github_id]; - const actor = actor_slack_id ? `<@${actor_slack_id}>` : actor_github_id; - const payload = { - text: `${actor} , workflow “${workflow_name}” failed, repo: "${repo_name}", branch: "${branch_name}", PR: "${pr_html_url}". Please check it: ${run_url}.`, - channel: process.env.SLACK_CHANNEL, - }; - return JSON.stringify(payload); - result-encoding: string - - - name: Send Slack Message - uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 - with: - payload: ${{ steps.generate-payload.outputs.result }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GATEWAY_NOTIFICATIONS_WEBHOOK }}