From 38475a46a1c0cdcf0deab1278f69fd15fb0e5a37 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 10:31:12 +0500 Subject: [PATCH 01/66] Create notify-dependabot.yml --- .github/notify-dependabot.yml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/notify-dependabot.yml diff --git a/.github/notify-dependabot.yml b/.github/notify-dependabot.yml new file mode 100644 index 00000000..abc5a969 --- /dev/null +++ b/.github/notify-dependabot.yml @@ -0,0 +1,52 @@ +name: Handle Dependabot PRs + +on: + pull_request: + types: [opened, synchronize, labeled] + +jobs: + handle: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: Send Slack Notification + uses: slackapi/slack-github-action@v1.24.0 + with: + payload: | + { + "text": "New Dependabot PR opened in *${{ github.repository }}*:\n*<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>*" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Close PR if checks fail + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + + const checks = await github.rest.checks.listForRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: pr.data.head.sha + }); + + const anyFailed = checks.data.check_runs.some(c => c.conclusion === 'failure'); + + if (anyFailed) { + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.data.number, + state: 'closed' + }); + + console.log('PR closed due to failed checks.'); + } else { + console.log('All checks passed.'); + } From c483cf06b43c40262f2842b8d63b268aaaf0ff14 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 10:34:37 +0500 Subject: [PATCH 02/66] Update notify-dependabot.yml --- .github/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/notify-dependabot.yml b/.github/notify-dependabot.yml index abc5a969..a83a4fd5 100644 --- a/.github/notify-dependabot.yml +++ b/.github/notify-dependabot.yml @@ -7,7 +7,7 @@ on: jobs: handle: runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' + if: github.actor != 'some-random-user' steps: - name: Send Slack Notification uses: slackapi/slack-github-action@v1.24.0 From 6cccbd251c1425a261a50c55f58c360899a37190 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 10:46:55 +0500 Subject: [PATCH 03/66] Update notify-dependabot.yml --- .github/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/notify-dependabot.yml b/.github/notify-dependabot.yml index a83a4fd5..abc5a969 100644 --- a/.github/notify-dependabot.yml +++ b/.github/notify-dependabot.yml @@ -7,7 +7,7 @@ on: jobs: handle: runs-on: ubuntu-latest - if: github.actor != 'some-random-user' + if: github.actor == 'dependabot[bot]' steps: - name: Send Slack Notification uses: slackapi/slack-github-action@v1.24.0 From 021ed868ef30b19c5d914681051906018735eb5a Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 12:26:51 +0500 Subject: [PATCH 04/66] Update notify-dependabot.yml --- .github/notify-dependabot.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/notify-dependabot.yml b/.github/notify-dependabot.yml index abc5a969..7d34335f 100644 --- a/.github/notify-dependabot.yml +++ b/.github/notify-dependabot.yml @@ -2,25 +2,24 @@ name: Handle Dependabot PRs on: pull_request: + branches: + - 'dependabot/**' types: [opened, synchronize, labeled] jobs: handle: runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' steps: - - name: Send Slack Notification + - name: Send message to Slack uses: slackapi/slack-github-action@v1.24.0 with: - payload: | - { - "text": "New Dependabot PR opened in *${{ github.repository }}*:\n*<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>*" - } + slack-message: "New Dependabot PR opened in *${{ github.repository }}*:\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - name: Close PR if checks fail uses: actions/github-script@v7 + if: github.actor == 'dependabot[bot]' # Only run for Dependabot PRs with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -29,15 +28,12 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number, }); - const checks = await github.rest.checks.listForRef({ owner: context.repo.owner, repo: context.repo.repo, ref: pr.data.head.sha }); - const anyFailed = checks.data.check_runs.some(c => c.conclusion === 'failure'); - if (anyFailed) { await github.rest.pulls.update({ owner: context.repo.owner, @@ -45,7 +41,6 @@ jobs: pull_number: pr.data.number, state: 'closed' }); - console.log('PR closed due to failed checks.'); } else { console.log('All checks passed.'); From 7c0782b6b54a649c3c02d2aac046ebc2150cb92c Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 12:30:48 +0500 Subject: [PATCH 05/66] Update APIMatic.Core.csproj --- APIMatic.Core/APIMatic.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APIMatic.Core/APIMatic.Core.csproj b/APIMatic.Core/APIMatic.Core.csproj index e951f270..02d37fb2 100644 --- a/APIMatic.Core/APIMatic.Core.csproj +++ b/APIMatic.Core/APIMatic.Core.csproj @@ -38,7 +38,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + From c92a3dabd2e742313516f8d454495d3bd180cc5f Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 12:52:15 +0500 Subject: [PATCH 06/66] Update dependabot.yml --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4c80518b..cf1f835e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ updates: - package-ecosystem: "nuget" directory: "/" schedule: - interval: "monthly" + interval: "daily" labels: - "dependency update" commit-message: From 4c6968b35c2f29bf2ef07987c7b188b8ef627c39 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 13:31:56 +0500 Subject: [PATCH 07/66] Create notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/notify-dependabot.yml diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml new file mode 100644 index 00000000..3a3d9e03 --- /dev/null +++ b/.github/workflows/notify-dependabot.yml @@ -0,0 +1,48 @@ +name: Handle Dependabot PRs + +on: + workflow_dispatch: +# pull_request: +# branches: +# - 'dependabot/**' +# types: [opened, synchronize, labeled] + +jobs: + handle: + runs-on: ubuntu-latest + steps: + - name: Send message to Slack + uses: slackapi/slack-github-action@v1.24.0 + with: + slack-message: "New Dependabot PR opened in *${{ github.repository }}*:\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Close PR if checks fail + uses: actions/github-script@v7 + if: github.actor == 'dependabot[bot]' # Only run for Dependabot PRs + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + const checks = await github.rest.checks.listForRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: pr.data.head.sha + }); + const anyFailed = checks.data.check_runs.some(c => c.conclusion === 'failure'); + if (anyFailed) { + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.data.number, + state: 'closed' + }); + console.log('PR closed due to failed checks.'); + } else { + console.log('All checks passed.'); + } From e6c19ba671996fc78a6c8be815d820a5273926fc Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 13:32:56 +0500 Subject: [PATCH 08/66] Delete .github/notify-dependabot.yml --- .github/notify-dependabot.yml | 47 ----------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .github/notify-dependabot.yml diff --git a/.github/notify-dependabot.yml b/.github/notify-dependabot.yml deleted file mode 100644 index 7d34335f..00000000 --- a/.github/notify-dependabot.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Handle Dependabot PRs - -on: - pull_request: - branches: - - 'dependabot/**' - types: [opened, synchronize, labeled] - -jobs: - handle: - runs-on: ubuntu-latest - steps: - - name: Send message to Slack - uses: slackapi/slack-github-action@v1.24.0 - with: - slack-message: "New Dependabot PR opened in *${{ github.repository }}*:\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - - name: Close PR if checks fail - uses: actions/github-script@v7 - if: github.actor == 'dependabot[bot]' # Only run for Dependabot PRs - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const pr = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }); - const checks = await github.rest.checks.listForRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: pr.data.head.sha - }); - const anyFailed = checks.data.check_runs.some(c => c.conclusion === 'failure'); - if (anyFailed) { - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pr.data.number, - state: 'closed' - }); - console.log('PR closed due to failed checks.'); - } else { - console.log('All checks passed.'); - } From fedbcab676bbf2f64593857ec98b11b6ced64970 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:00:08 +0500 Subject: [PATCH 09/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 43 +++---------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 3a3d9e03..1f8a3c00 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,48 +1,15 @@ -name: Handle Dependabot PRs +name: Test Dependabot Slack Alert on: - workflow_dispatch: -# pull_request: -# branches: -# - 'dependabot/**' -# types: [opened, synchronize, labeled] + workflow_dispatch: # Manual trigger jobs: - handle: + test-slack: runs-on: ubuntu-latest steps: - - name: Send message to Slack + - name: Send test message to Slack uses: slackapi/slack-github-action@v1.24.0 - with: - slack-message: "New Dependabot PR opened in *${{ github.repository }}*:\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - - name: Close PR if checks fail - uses: actions/github-script@v7 - if: github.actor == 'dependabot[bot]' # Only run for Dependabot PRs with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const pr = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }); - const checks = await github.rest.checks.listForRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: pr.data.head.sha - }); - const anyFailed = checks.data.check_runs.some(c => c.conclusion === 'failure'); - if (anyFailed) { - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pr.data.number, - state: 'closed' - }); - console.log('PR closed due to failed checks.'); - } else { - console.log('All checks passed.'); - } + slack-message: "TEST: Manual workflow triggered in *${{ github.repository }}*" From e31df963a649c3c8de6bb07fe63d9edf6a506cd4 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:05:26 +0500 Subject: [PATCH 10/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 1f8a3c00..2bc06e31 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Send test message to Slack - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: From a60a4c2de101612f1dec782f5fbd1b2a16daf055 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:12:54 +0500 Subject: [PATCH 11/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 31 +++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 2bc06e31..0833be4f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,15 +1,32 @@ -name: Test Dependabot Slack Alert - -on: - workflow_dispatch: # Manual trigger +name: Dependabot Slack Notifications +on: workflow_dispatch jobs: - test-slack: + notify: runs-on: ubuntu-latest steps: - - name: Send test message to Slack + - name: Send Slack notification uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: - slack-message: "TEST: Manual workflow triggered in *${{ github.repository }}*" + slack-message: | + { + "text": "New Dependabot activity in ${{ github.repository }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "šŸš€ *New Dependabot PR*" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "• Repository: \n• PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" + } + } + ] + } From 534c19cf6a25be5ac62e0d280dc4c2bf7ed1a13f Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:20:57 +0500 Subject: [PATCH 12/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 47 ++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 0833be4f..1be7a97b 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,32 +1,31 @@ name: Dependabot Slack Notifications + on: workflow_dispatch jobs: notify: runs-on: ubuntu-latest steps: - - name: Send Slack notification - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - slack-message: | - { - "text": "New Dependabot activity in ${{ github.repository }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "šŸš€ *New Dependabot PR*" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "• Repository: \n• PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" - } + - name: Send Slack notification (via curl) + run: | + curl -X POST -H 'Content-type: application/json' \ + --data '{ + "text": "šŸš€ *New Dependabot PR* in `${{ github.repository }}`", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "šŸš€ *New Dependabot PR*" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "• Repository: \n• PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" } - ] - } + } + ] + }' \ + ${{ secrets.SLACK_WEBHOOK_URL }} From e4d8cf03a7106185ce4b21b6de88c98077a94f8e Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:26:17 +0500 Subject: [PATCH 13/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 53 +++++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 1be7a97b..ec38aa75 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -9,23 +9,50 @@ jobs: - name: Send Slack notification (via curl) run: | curl -X POST -H 'Content-type: application/json' \ - --data '{ - "text": "šŸš€ *New Dependabot PR* in `${{ github.repository }}`", - "blocks": [ + --data "{ + \"text\": \"šŸš€ New Dependabot PR created\", + \"blocks\": [ { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "šŸš€ *New Dependabot PR*" + \"type\": \"header\", + \"text\": { + \"type\": \"plain_text\", + \"text\": \"šŸš€ New Dependabot PR\" } }, { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "• Repository: \n• PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" - } + \"type\": \"section\", + \"fields\": [ + { + \"type\": \"mrkdwn\", + \"text\": \"*Repository:*\n\" + }, + { + \"type\": \"mrkdwn\", + \"text\": \"*Author:*\n${{ github.actor }}\" + }, + { + \"type\": \"mrkdwn\", + \"text\": \"*PR Title:*\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>\" + }, + { + \"type\": \"mrkdwn\", + \"text\": \"*Branch:*\n${{ github.head_ref || github.ref_name }}\" + }, + { + \"type\": \"mrkdwn\", + \"text\": \"*PR Number:*\n#${{ github.event.pull_request.number }}\" + } + ] + }, + { + \"type\": \"context\", + \"elements\": [ + { + \"type\": \"mrkdwn\", + \"text\": \"šŸ”Ž Dependabot PR triggered via manual workflow\" + } + ] } ] - }' \ + }" \ ${{ secrets.SLACK_WEBHOOK_URL }} From 762e2c1dd828762a25b4c12c2abf6abf1c43885f Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:31:08 +0500 Subject: [PATCH 14/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 98 ++++++++++++------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index ec38aa75..395e36d5 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,58 +1,56 @@ name: Dependabot Slack Notifications -on: workflow_dispatch +on: + pull_request: + branches: + - 'dependabot/**' + types: [opened, synchronize, labeled] jobs: notify: runs-on: ubuntu-latest + steps: - - name: Send Slack notification (via curl) - run: | - curl -X POST -H 'Content-type: application/json' \ - --data "{ - \"text\": \"šŸš€ New Dependabot PR created\", - \"blocks\": [ - { - \"type\": \"header\", - \"text\": { - \"type\": \"plain_text\", - \"text\": \"šŸš€ New Dependabot PR\" - } - }, - { - \"type\": \"section\", - \"fields\": [ - { - \"type\": \"mrkdwn\", - \"text\": \"*Repository:*\n\" - }, - { - \"type\": \"mrkdwn\", - \"text\": \"*Author:*\n${{ github.actor }}\" - }, - { - \"type\": \"mrkdwn\", - \"text\": \"*PR Title:*\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>\" - }, - { - \"type\": \"mrkdwn\", - \"text\": \"*Branch:*\n${{ github.head_ref || github.ref_name }}\" - }, - { - \"type\": \"mrkdwn\", - \"text\": \"*PR Number:*\n#${{ github.event.pull_request.number }}\" + - name: Send Slack notification + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + slack-message: | + { + "text": "New Dependabot PR Notification", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":rocket: *New Dependabot PR*" } - ] - }, - { - \"type\": \"context\", - \"elements\": [ - { - \"type\": \"mrkdwn\", - \"text\": \"šŸ”Ž Dependabot PR triggered via manual workflow\" - } - ] - } - ] - }" \ - ${{ secrets.SLACK_WEBHOOK_URL }} + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository:*\n" + }, + { + "type": "mrkdwn", + "text": "*Branch:*\n${{ github.event.pull_request.base.ref }}" + }, + { + "type": "mrkdwn", + "text": "*PR Number:*\n#${{ github.event.pull_request.number }}" + } + ] + } + ] + } From 3815d0b3741753724468aa30e89ce048f7923451 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:33:46 +0500 Subject: [PATCH 15/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 395e36d5..8843c2cd 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,10 +1,7 @@ name: Dependabot Slack Notifications on: - pull_request: - branches: - - 'dependabot/**' - types: [opened, synchronize, labeled] + workflow_dispatch: jobs: notify: From 0a5be8be3818f88857a2437333596f18cc71c860 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:35:58 +0500 Subject: [PATCH 16/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 8843c2cd..9c16cfae 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,6 +2,10 @@ name: Dependabot Slack Notifications on: workflow_dispatch: + pull_request: + branches: + - 'dependabot/**' + types: [opened, synchronize, labeled] jobs: notify: From 0e0fadedd3bdb06cc9d1c31cd3649826cc70148c Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:37:54 +0500 Subject: [PATCH 17/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 9c16cfae..ee849349 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,10 +2,6 @@ name: Dependabot Slack Notifications on: workflow_dispatch: - pull_request: - branches: - - 'dependabot/**' - types: [opened, synchronize, labeled] jobs: notify: @@ -19,7 +15,7 @@ jobs: with: slack-message: | { - "text": "New Dependabot PR Notification", + "text": "Manual Dependabot PR Test Notification", "blocks": [ { "type": "section", @@ -33,7 +29,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository:*\n" + "text": "*PR Title:*\n" }, { "type": "mrkdwn", - "text": "*Branch:*\n${{ github.event.pull_request.base.ref }}" + "text": "*Branch:*\nmain" }, { "type": "mrkdwn", - "text": "*PR Number:*\n#${{ github.event.pull_request.number }}" + "text": "*PR Number:*\n#123" } ] } From 4d23050240b0e86d75058a7d0fcb0628cae79cb2 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:39:43 +0500 Subject: [PATCH 18/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index ee849349..3ae9532a 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -13,9 +13,9 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: - slack-message: | + payload: | { - "text": "Manual Dependabot PR Test Notification", + "text": "šŸš€ *New Dependabot PR*", "blocks": [ { "type": "section", From 7382c33623c6492c543ac31b8dad2301c190b7f9 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:42:38 +0500 Subject: [PATCH 19/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 3ae9532a..deaa734e 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -29,7 +29,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository:*\n" }, { "type": "mrkdwn", From 95ecb9c3fa5e07d0309c90d0ded577a1797629d9 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:45:39 +0500 Subject: [PATCH 20/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 47 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index deaa734e..5dac1216 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -15,13 +15,14 @@ jobs: with: payload: | { - "text": "šŸš€ *New Dependabot PR*", + "text": "šŸš€ New Dependabot PR: ${{ github.event.pull_request.title }}", "blocks": [ { - "type": "section", + "type": "header", "text": { - "type": "mrkdwn", - "text": ":rocket: *New Dependabot PR*" + "type": "plain_text", + "text": "šŸš€ New Dependabot PR", + "emoji": true } }, { @@ -33,19 +34,45 @@ jobs: }, { "type": "mrkdwn", - "text": "*Author:*\n${{ github.actor }}" - }, + "text": "*PR Number:*\n<${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>" + } + ] + }, + { + "type": "section", + "fields": [ { "type": "mrkdwn", - "text": "*PR Title:*\n" + "text": "*Title:*\n${{ github.event.pull_request.title }}" }, { "type": "mrkdwn", - "text": "*Branch:*\nmain" + "text": "*Branch:*\n${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View PR", + "emoji": true + }, + "url": "${{ github.event.pull_request.html_url }}", + "style": "primary" }, { - "type": "mrkdwn", - "text": "*PR Number:*\n#123" + "type": "button", + "text": { + "type": "plain_text", + "text": "Approve", + "emoji": true + }, + "url": "${{ github.event.pull_request.html_url }}/files#submit-review", + "style": "danger" } ] } From 9523d124d6d720ee7abfba33ebdfceda8389723f Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:49:30 +0500 Subject: [PATCH 21/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 45 +++++++------------------ 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 5dac1216..865ba324 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -15,13 +15,13 @@ jobs: with: payload: | { - "text": "šŸš€ New Dependabot PR: ${{ github.event.pull_request.title }}", + "text": "šŸš€ Dependabot Notification", "blocks": [ { "type": "header", "text": { "type": "plain_text", - "text": "šŸš€ New Dependabot PR", + "text": "šŸš€ Dependabot Notification", "emoji": true } }, @@ -34,45 +34,26 @@ jobs: }, { "type": "mrkdwn", - "text": "*PR Number:*\n<${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>" + "text": "*Triggered by:*\n${{ github.actor }}" } ] }, { "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title:*\n${{ github.event.pull_request.title }}" - }, - { - "type": "mrkdwn", - "text": "*Branch:*\n${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}" - } - ] + "text": { + "type": "mrkdwn", + "text": "This is a manually triggered notification about Dependabot updates." + } + }, + { + "type": "divider" }, { - "type": "actions", + "type": "context", "elements": [ { - "type": "button", - "text": { - "type": "plain_text", - "text": "View PR", - "emoji": true - }, - "url": "${{ github.event.pull_request.html_url }}", - "style": "primary" - }, - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Approve", - "emoji": true - }, - "url": "${{ github.event.pull_request.html_url }}/files#submit-review", - "style": "danger" + "type": "mrkdwn", + "text": "ā„¹ļø *Note:* This notification was triggered manually. For automated PR notifications, use the `pull_request` trigger." } ] } From c979f76cd7dc4c18e9c072360edb6745883652dc Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:53:37 +0500 Subject: [PATCH 22/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 41 +++++++++---------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 865ba324..30faf922 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -6,7 +6,6 @@ on: jobs: notify: runs-on: ubuntu-latest - steps: - name: Send Slack notification uses: slackapi/slack-github-action@v1.25.0 @@ -15,47 +14,35 @@ jobs: with: payload: | { - "text": "šŸš€ Dependabot Notification", + "text": "PR open ${{ github.repository }}", "blocks": [ { - "type": "header", + "type": "section", "text": { - "type": "plain_text", - "text": "šŸš€ Dependabot Notification", - "emoji": true + "type": "mrkdwn", + "text": "*PR open* " } }, { "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository:*\n" - }, - { - "type": "mrkdwn", - "text": "*Triggered by:*\n${{ github.actor }}" - } - ] + "text": { + "type": "mrkdwn", + "text": "*PR title:* [Manual trigger - no PR title]" + } }, { "type": "section", "text": { "type": "mrkdwn", - "text": "This is a manually triggered notification about Dependabot updates." + "text": "*PR author:* ${{ github.actor }}" } }, { - "type": "divider" - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "ā„¹ļø *Note:* This notification was triggered manually. For automated PR notifications, use the `pull_request` trigger." - } - ] + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR link:* [Manual trigger - no PR link]" + } } ] } From e34bead88f25e9aa7d2d0b552258e24871d79a18 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:56:12 +0500 Subject: [PATCH 23/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 30faf922..60d6f13e 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,6 +2,15 @@ name: Dependabot Slack Notifications on: workflow_dispatch: + inputs: + pr_title: + description: 'PR Title' + required: false + default: '[Manual trigger - no PR title]' + pr_link: + description: 'PR Link' + required: false + default: '[Manual trigger - no PR link]' jobs: notify: @@ -14,34 +23,32 @@ jobs: with: payload: | { - "text": "PR open ${{ github.repository }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR open* " + "text": " *PR Open*: " } }, { "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR title:* [Manual trigger - no PR title]" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR author:* ${{ github.actor }}" - } + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n${{ inputs.pr_title || github.event.pull_request.title || '[No title provided]' }}" + }, + { + "type": "mrkdwn", + "text": "*Author*\n${{ github.actor || github.event.pull_request.user.login || '[Unknown author]' }}" + } + ] }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR link:* [Manual trigger - no PR link]" + "text": "*Link*\n${{ inputs.pr_link || github.event.pull_request.html_url || '[No link available]' }}" } } ] From 17f8352dcb7356f001955c39a75b90074be42533 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 14:57:11 +0500 Subject: [PATCH 24/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 37 +++++++++++-------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 60d6f13e..5bb887b6 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,15 +2,8 @@ name: Dependabot Slack Notifications on: workflow_dispatch: - inputs: - pr_title: - description: 'PR Title' - required: false - default: '[Manual trigger - no PR title]' - pr_link: - description: 'PR Link' - required: false - default: '[Manual trigger - no PR link]' + pull_request: + types: [opened] jobs: notify: @@ -23,32 +16,34 @@ jobs: with: payload: | { + "text": "PR open ${{ github.repository }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": " *PR Open*: " + "text": "*PR open* " } }, { "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title*\n${{ inputs.pr_title || github.event.pull_request.title || '[No title provided]' }}" - }, - { - "type": "mrkdwn", - "text": "*Author*\n${{ github.actor || github.event.pull_request.user.login || '[Unknown author]' }}" - } - ] + "text": { + "type": "mrkdwn", + "text": "*PR title:* ${{ github.event.pull_request.title || '[Manual trigger - no PR title]' }}" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR author:* ${{ github.event.pull_request.user.login || github.actor }}" + } }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*Link*\n${{ inputs.pr_link || github.event.pull_request.html_url || '[No link available]' }}" + "text": "*PR link:* ${{ github.event.pull_request.html_url || '[Manual trigger - no PR link]' }}" } } ] From e1fc8e1c82b01bd22610c829bae3d94f7dca8978 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:01:27 +0500 Subject: [PATCH 25/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 115 ++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 9 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 5bb887b6..76681394 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,49 +1,146 @@ -name: Dependabot Slack Notifications +name: Dependabot PR Manager on: workflow_dispatch: pull_request: - types: [opened] + types: [opened, closed] jobs: notify: runs-on: ubuntu-latest steps: - - name: Send Slack notification + - name: Send PR notification + if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "PR open ${{ github.repository }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR open* " + "text": "šŸ“¦ *${{ github.event.pull_request && 'Dependabot PR' || 'Manual PR Notification' }* opened" } }, { "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number || 'N/A' }}" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title || inputs.pr_title || '[Manual trigger]' }}" + }, + { + "type": "mrkdwn", + "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View PR", + "emoji": true + }, + "url": "${{ github.event.pull_request.html_url || inputs.pr_link || 'https://github.com/' + github.repository + '/pulls' }}" + } + ] + } + ] + } + + monitor_checks: + if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' + runs-on: ubuntu-latest + needs: notify + steps: + - name: Wait for checks + uses: fountainhead/action-wait-for-check@v1.0.0 + id: wait-for-check + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.event.pull_request.head.sha }} + timeout-seconds: 600 + interval-seconds: 30 + + - name: Check PR status + id: check-pr-status + run: | + if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then + echo "PR checks passed" + else + echo "PR checks failed - closing PR" + echo "::set-output name=should_close::true" + fi + + - name: Close failed PR + if: steps.check-pr-status.outputs.should_close == 'true' + uses: superbrothers/close-pull-request@v3 + with: + comment: "Automatically closed due to failed checks" + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Slack about closed PR + if: steps.check-pr-status.outputs.should_close == 'true' + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + payload: | + { + "blocks": [ + { + "type": "header", "text": { - "type": "mrkdwn", - "text": "*PR title:* ${{ github.event.pull_request.title || '[Manual trigger - no PR title]' }}" + "type": "plain_text", + "text": "āŒ Dependabot PR Closed", + "emoji": true } }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n${{ github.repository }}" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + } + ] + }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR author:* ${{ github.event.pull_request.user.login || github.actor }}" + "text": "*Reason*\nAutomatically closed due to failed checks" } }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR link:* ${{ github.event.pull_request.html_url || '[Manual trigger - no PR link]' }}" + "text": "*Failed Checks*\n${{ steps.wait-for-check.outputs.failed-checks }}" } } ] From 75ceca34741475b3725f84763f78d7963232fe04 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:03:25 +0500 Subject: [PATCH 26/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 76681394..3dfe38b5 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -22,7 +22,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "šŸ“¦ *${{ github.event.pull_request && 'Dependabot PR' || 'Manual PR Notification' }* opened" + "text": "šŸ“¦ *${{ github.event.pull_request && 'Dependabot PR' || 'Manual PR Notification' }}* opened" } }, { @@ -43,7 +43,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || inputs.pr_title || '[Manual trigger]' }}" + "text": "*Title*\n${{ github.event.pull_request.title || '[Manual trigger]' }}" }, { "type": "mrkdwn", @@ -61,7 +61,7 @@ jobs: "text": "View PR", "emoji": true }, - "url": "${{ github.event.pull_request.html_url || inputs.pr_link || 'https://github.com/' + github.repository + '/pulls' }}" + "url": "${{ github.event.pull_request.html_url || 'https://github.com/' + github.repository + '/pulls' }}" } ] } @@ -89,7 +89,7 @@ jobs: echo "PR checks passed" else echo "PR checks failed - closing PR" - echo "::set-output name=should_close::true" + echo "should_close=true" >> $GITHUB_OUTPUT fi - name: Close failed PR @@ -135,13 +135,6 @@ jobs: "type": "mrkdwn", "text": "*Reason*\nAutomatically closed due to failed checks" } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Failed Checks*\n${{ steps.wait-for-check.outputs.failed-checks }}" - } } ] } From 34623f1fc9f1093459de06f9145a68894dbfb3e6 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:05:35 +0500 Subject: [PATCH 27/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 3dfe38b5..ffbffd82 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,6 +2,13 @@ name: Dependabot PR Manager on: workflow_dispatch: + inputs: + pr_title: + description: 'PR Title (for manual triggers)' + required: false + pr_link: + description: 'PR Link (for manual triggers)' + required: false pull_request: types: [opened, closed] @@ -22,7 +29,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "šŸ“¦ *${{ github.event.pull_request && 'Dependabot PR' || 'Manual PR Notification' }}* opened" + "text": ":package: *PR Opened*" } }, { @@ -34,7 +41,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number || 'N/A' }}" + "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" } ] }, @@ -43,7 +50,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || '[Manual trigger]' }}" + "text": "*Title*\n${{ github.event.pull_request.title || inputs.pr_title || 'Manual notification' }}" }, { "type": "mrkdwn", @@ -61,7 +68,7 @@ jobs: "text": "View PR", "emoji": true }, - "url": "${{ github.event.pull_request.html_url || 'https://github.com/' + github.repository + '/pulls' }}" + "url": "${{ github.event.pull_request.html_url || inputs.pr_link || format('https://github.com/{0}/pulls', github.repository) }}" } ] } From bdf219505a280be878ba59395d51713ef2ab8b4e Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:09:34 +0500 Subject: [PATCH 28/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index ffbffd82..e1f65c1f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,13 +2,6 @@ name: Dependabot PR Manager on: workflow_dispatch: - inputs: - pr_title: - description: 'PR Title (for manual triggers)' - required: false - pr_link: - description: 'PR Link (for manual triggers)' - required: false pull_request: types: [opened, closed] @@ -24,12 +17,13 @@ jobs: with: payload: | { + "text": "New PR Notification: ${{ github.event.pull_request.title || 'Manual workflow trigger' }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": ":package: *PR Opened*" + "text": ":package: *PR Notification*" } }, { @@ -50,7 +44,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || inputs.pr_title || 'Manual notification' }}" + "text": "*Title*\n${{ github.event.pull_request.title || 'Manual notification' }}" }, { "type": "mrkdwn", @@ -68,7 +62,7 @@ jobs: "text": "View PR", "emoji": true }, - "url": "${{ github.event.pull_request.html_url || inputs.pr_link || format('https://github.com/{0}/pulls', github.repository) }}" + "url": "${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}" } ] } @@ -114,6 +108,7 @@ jobs: with: payload: | { + "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks", "blocks": [ { "type": "header", From a1c4f6cb080f1e160155b911ab2792ec99aabfd3 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:13:36 +0500 Subject: [PATCH 29/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 36 ++++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index e1f65c1f..6397d589 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -17,13 +17,15 @@ jobs: with: payload: | { - "text": "New PR Notification: ${{ github.event.pull_request.title || 'Manual workflow trigger' }}", + "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", + "username": "Dependabot Manager", + "icon_emoji": ":robot_face:", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": ":package: *PR Notification*" + "text": ":package: *New PR Notification* :package:" } }, { @@ -44,7 +46,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || 'Manual notification' }}" + "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" }, { "type": "mrkdwn", @@ -53,18 +55,11 @@ jobs: ] }, { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "View PR", - "emoji": true - }, - "url": "${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}" - } - ] + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" + } } ] } @@ -108,7 +103,9 @@ jobs: with: payload: | { - "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks", + "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "username": "Dependabot Manager", + "icon_emoji": ":warning:", "blocks": [ { "type": "header", @@ -131,6 +128,13 @@ jobs: } ] }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title }}" + } + }, { "type": "section", "text": { From 67361029f2f64dda911f945872abd341449884a5 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:48:27 +0500 Subject: [PATCH 30/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 120 +++++++++++++----------- 1 file changed, 67 insertions(+), 53 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 6397d589..39872f3d 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -2,30 +2,79 @@ name: Dependabot PR Manager on: workflow_dispatch: + check_suite: + types: [completed] pull_request: - types: [opened, closed] + types: [closed] jobs: - notify: + monitor_checks: + if: github.actor == 'dependabot[bot]' && github.event.check_suite.conclusion != 'skipped' runs-on: ubuntu-latest steps: - - name: Send PR notification - if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' + - name: Get PR information + id: pr-info + uses: octokit/request-action@v2.x + with: + route: GET /repos/${{ github.repository }}/commits/${{ github.event.check_suite.head_sha }}/pulls + mediaType: | + { + "previews": ["groot"] + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract PR number + id: extract-pr + run: | + PR_DATA=$(echo '${{ steps.pr-info.outputs.data }}' | jq -r '.[0]') + if [ -z "$PR_DATA" ] || [ "$PR_DATA" == "null" ]; then + echo "No PR associated with this commit" + echo "pr_number=0" >> $GITHUB_OUTPUT + exit 0 + fi + echo "pr_number=$(echo "$PR_DATA" | jq -r '.number')" >> $GITHUB_OUTPUT + echo "pr_title=$(echo "$PR_DATA" | jq -r '.title')" >> $GITHUB_OUTPUT + echo "pr_user=$(echo "$PR_DATA" | jq -r '.user.login')" >> $GITHUB_OUTPUT + echo "pr_url=$(echo "$PR_DATA" | jq -r '.html_url')" >> $GITHUB_OUTPUT + + - name: Check PR status + id: check-pr-status + run: | + if [[ "${{ github.event.check_suite.conclusion }}" == "success" ]]; then + echo "PR checks passed" + echo "should_notify=true" >> $GITHUB_OUTPUT + else + echo "PR checks failed - closing PR" + echo "should_close=true" >> $GITHUB_OUTPUT + fi + + - name: Close failed PR + if: steps.check-pr-status.outputs.should_close == 'true' && steps.extract-pr.outputs.pr_number != '0' + uses: superbrothers/close-pull-request@v3 + with: + comment: "Automatically closed due to failed checks" + token: ${{ secrets.GITHUB_TOKEN }} + pull_request_number: ${{ steps.extract-pr.outputs.pr_number }} + + - name: Notify Slack about successful PR + if: steps.check-pr-status.outputs.should_notify == 'true' && steps.extract-pr.outputs.pr_number != '0' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", + "text": "Dependabot PR #${{ steps.extract-pr.outputs.pr_number }} passed checks in ${{ github.repository }}", "username": "Dependabot Manager", - "icon_emoji": ":robot_face:", + "icon_emoji": ":white_check_mark:", "blocks": [ { - "type": "section", + "type": "header", "text": { - "type": "mrkdwn", - "text": ":package: *New PR Notification* :package:" + "type": "plain_text", + "text": "āœ… Dependabot PR Ready", + "emoji": true } }, { @@ -37,7 +86,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" + "text": "*PR Number*\n#${{ steps.extract-pr.outputs.pr_number }}" } ] }, @@ -46,11 +95,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" + "text": "*Title*\n${{ steps.extract-pr.outputs.pr_title }}" }, { "type": "mrkdwn", - "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" + "text": "*Author*\n${{ steps.extract-pr.outputs.pr_user }}" } ] }, @@ -58,60 +107,32 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" + "text": "*PR Link*\n<${{ steps.extract-pr.outputs.pr_url }}|View PR>" } } ] } - monitor_checks: - if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' + notify_closed: + if: github.actor == 'dependabot[bot]' && github.event.action == 'closed' runs-on: ubuntu-latest - needs: notify steps: - - name: Wait for checks - uses: fountainhead/action-wait-for-check@v1.0.0 - id: wait-for-check - with: - token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ github.event.pull_request.head.sha }} - timeout-seconds: 600 - interval-seconds: 30 - - - name: Check PR status - id: check-pr-status - run: | - if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then - echo "PR checks passed" - else - echo "PR checks failed - closing PR" - echo "should_close=true" >> $GITHUB_OUTPUT - fi - - - name: Close failed PR - if: steps.check-pr-status.outputs.should_close == 'true' - uses: superbrothers/close-pull-request@v3 - with: - comment: "Automatically closed due to failed checks" - token: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack about closed PR - if: steps.check-pr-status.outputs.should_close == 'true' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed in ${{ github.repository }}", "username": "Dependabot Manager", - "icon_emoji": ":warning:", + "icon_emoji": ":package:", "blocks": [ { "type": "header", "text": { "type": "plain_text", - "text": "āŒ Dependabot PR Closed", + "text": "šŸ“¦ Dependabot PR Closed", "emoji": true } }, @@ -134,13 +155,6 @@ jobs: "type": "mrkdwn", "text": "*Title*\n${{ github.event.pull_request.title }}" } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Reason*\nAutomatically closed due to failed checks" - } } ] } From 6d8cd4f27468cec54b367922b47370db4a1dd607 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 15:57:41 +0500 Subject: [PATCH 31/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 141 +++++------------------- 1 file changed, 25 insertions(+), 116 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 39872f3d..f47c9658 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,159 +1,68 @@ -name: Dependabot PR Manager +name: Handle Completed Dependabot PR Checks on: - workflow_dispatch: check_suite: types: [completed] - pull_request: - types: [closed] jobs: - monitor_checks: - if: github.actor == 'dependabot[bot]' && github.event.check_suite.conclusion != 'skipped' + handle_dependabot_checks: + if: > + github.event.check_suite.pull_requests != null && + github.event.check_suite.pull_requests[0].user.login == 'dependabot[bot]' runs-on: ubuntu-latest - steps: - - name: Get PR information - id: pr-info - uses: octokit/request-action@v2.x - with: - route: GET /repos/${{ github.repository }}/commits/${{ github.event.check_suite.head_sha }}/pulls - mediaType: | - { - "previews": ["groot"] - } - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Extract PR number - id: extract-pr - run: | - PR_DATA=$(echo '${{ steps.pr-info.outputs.data }}' | jq -r '.[0]') - if [ -z "$PR_DATA" ] || [ "$PR_DATA" == "null" ]; then - echo "No PR associated with this commit" - echo "pr_number=0" >> $GITHUB_OUTPUT - exit 0 - fi - echo "pr_number=$(echo "$PR_DATA" | jq -r '.number')" >> $GITHUB_OUTPUT - echo "pr_title=$(echo "$PR_DATA" | jq -r '.title')" >> $GITHUB_OUTPUT - echo "pr_user=$(echo "$PR_DATA" | jq -r '.user.login')" >> $GITHUB_OUTPUT - echo "pr_url=$(echo "$PR_DATA" | jq -r '.html_url')" >> $GITHUB_OUTPUT - - - name: Check PR status - id: check-pr-status + steps: + - name: Extract PR Info + id: pr_info run: | - if [[ "${{ github.event.check_suite.conclusion }}" == "success" ]]; then - echo "PR checks passed" - echo "should_notify=true" >> $GITHUB_OUTPUT - else - echo "PR checks failed - closing PR" - echo "should_close=true" >> $GITHUB_OUTPUT - fi + echo "PR_NUMBER=$(jq '.[0].number' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV + echo "PR_TITLE=$(jq -r '.[0].title' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV + echo "PR_URL=$(jq -r '.[0].html_url' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - - name: Close failed PR - if: steps.check-pr-status.outputs.should_close == 'true' && steps.extract-pr.outputs.pr_number != '0' + - name: Close PR if checks failed + if: github.event.check_suite.conclusion != 'success' uses: superbrothers/close-pull-request@v3 with: - comment: "Automatically closed due to failed checks" - token: ${{ secrets.GITHUB_TOKEN }} - pull_request_number: ${{ steps.extract-pr.outputs.pr_number }} + pull-request-number: ${{ env.PR_NUMBER }} + comment: "Closed automatically due to failed checks." + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack about successful PR - if: steps.check-pr-status.outputs.should_notify == 'true' && steps.extract-pr.outputs.pr_number != '0' + - name: Notify Slack - PR Failed + if: github.event.check_suite.conclusion != 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "Dependabot PR #${{ steps.extract-pr.outputs.pr_number }} passed checks in ${{ github.repository }}", - "username": "Dependabot Manager", - "icon_emoji": ":white_check_mark:", + "text": ":x: Dependabot PR #${{ env.PR_NUMBER }} failed checks and was closed.", "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "āœ… Dependabot PR Ready", - "emoji": true - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n#${{ steps.extract-pr.outputs.pr_number }}" - } - ] - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title*\n${{ steps.extract-pr.outputs.pr_title }}" - }, - { - "type": "mrkdwn", - "text": "*Author*\n${{ steps.extract-pr.outputs.pr_user }}" - } - ] - }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link*\n<${{ steps.extract-pr.outputs.pr_url }}|View PR>" + "text": "*Closed PR:* <${{ env.PR_URL }}|${{ env.PR_TITLE }}> due to failed CI checks." } } ] } - notify_closed: - if: github.actor == 'dependabot[bot]' && github.event.action == 'closed' - runs-on: ubuntu-latest - steps: - - name: Notify Slack about closed PR + - name: Notify Slack - PR Success + if: github.event.check_suite.conclusion == 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed in ${{ github.repository }}", - "username": "Dependabot Manager", - "icon_emoji": ":package:", + "text": ":white_check_mark: Dependabot PR #${{ env.PR_NUMBER }} passed all checks.", "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "šŸ“¦ Dependabot PR Closed", - "emoji": true - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n${{ github.repository }}" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" - } - ] - }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title }}" + "text": "*Successful PR:* <${{ env.PR_URL }}|${{ env.PR_TITLE }}> passed all CI checks." } } ] From d52446c6600ce880db5120d8110c117e4816c958 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 16:17:26 +0500 Subject: [PATCH 32/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index f47c9658..4ce33614 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -20,7 +20,7 @@ jobs: echo "PR_URL=$(jq -r '.[0].html_url' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - name: Close PR if checks failed - if: github.event.check_suite.conclusion != 'success' + if: ${{ github.event.check_suite.conclusion != 'success' }} uses: superbrothers/close-pull-request@v3 with: pull-request-number: ${{ env.PR_NUMBER }} @@ -28,28 +28,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack - PR Failed - if: github.event.check_suite.conclusion != 'success' - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - payload: | - { - "text": ":x: Dependabot PR #${{ env.PR_NUMBER }} failed checks and was closed.", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Closed PR:* <${{ env.PR_URL }}|${{ env.PR_TITLE }}> due to failed CI checks." - } - } - ] - } - - name: Notify Slack - PR Success - if: github.event.check_suite.conclusion == 'success' + if: ${{ github.event.check_suite.conclusion == 'success' }} uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} From 08392cddebd22dc49af82653cae5d74a434c895c Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 16:28:05 +0500 Subject: [PATCH 33/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 182 +++++++++++++++++++++--- 1 file changed, 162 insertions(+), 20 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 4ce33614..73c107c9 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,48 +1,190 @@ -name: Handle Completed Dependabot PR Checks +name: Dependabot PR Manager on: + workflow_dispatch: check_suite: types: [completed] + status: {} + pull_request: + types: [closed] jobs: - handle_dependabot_checks: - if: > - github.event.check_suite.pull_requests != null && - github.event.check_suite.pull_requests[0].user.login == 'dependabot[bot]' + handle_checks: + # Run only for dependabot PRs when checks complete + if: | + github.actor == 'dependabot[bot]' && + (github.event_name == 'check_suite' || github.event_name == 'status') && + github.event.check_suite.conclusion != 'skipped' runs-on: ubuntu-latest - + steps: - - name: Extract PR Info - id: pr_info + - name: Get associated PRs + id: get-pr + uses: octokit/request-action@v2.x + with: + route: GET /repos/${{ github.repository }}/commits/${{ github.sha }}/pulls + mediaType: | + { + "previews": ["groot"] + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract PR info + id: pr-info run: | - echo "PR_NUMBER=$(jq '.[0].number' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - echo "PR_TITLE=$(jq -r '.[0].title' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - echo "PR_URL=$(jq -r '.[0].html_url' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV + PR_DATA=$(echo '${{ steps.get-pr.outputs.data }}' | jq -r '.[0]') + if [ -z "$PR_DATA" ] || [ "$PR_DATA" == "null" ]; then + echo "No PR associated with this commit" + echo "pr_number=0" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "pr_number=$(echo "$PR_DATA" | jq -r '.number')" >> $GITHUB_OUTPUT + echo "pr_title=$(echo "$PR_DATA" | jq -r '.title')" >> $GITHUB_OUTPUT + echo "pr_user=$(echo "$PR_DATA" | jq -r '.user.login')" >> $GITHUB_OUTPUT + echo "pr_url=$(echo "$PR_DATA" | jq -r '.html_url')" >> $GITHUB_OUTPUT + echo "pr_state=$(echo "$PR_DATA" | jq -r '.state')" >> $GITHUB_OUTPUT - - name: Close PR if checks failed - if: ${{ github.event.check_suite.conclusion != 'success' }} + - name: Determine check conclusion + id: check-conclusion + run: | + # For status events + if [ "${{ github.event_name }}" == "status" ]; then + if [ "${{ github.event.state }}" == "success" ]; then + echo "conclusion=success" >> $GITHUB_OUTPUT + else + echo "conclusion=failure" >> $GITHUB_OUTPUT + fi + # For check_suite events + else + echo "conclusion=${{ github.event.check_suite.conclusion }}" >> $GITHUB_OUTPUT + fi + + - name: Close unsuccessful PR + if: | + steps.pr-info.outputs.pr_number != '0' && + steps.pr-info.outputs.pr_state == 'open' && + steps.check-conclusion.outputs.conclusion != 'success' uses: superbrothers/close-pull-request@v3 with: - pull-request-number: ${{ env.PR_NUMBER }} - comment: "Closed automatically due to failed checks." + comment: "Automatically closed due to unsuccessful checks" + token: ${{ secrets.GITHUB_TOKEN }} + pull_request_number: ${{ steps.pr-info.outputs.pr_number }} + + - name: Notify Slack for successful PR + if: | + steps.pr-info.outputs.pr_number != '0' && + steps.check-conclusion.outputs.conclusion == 'success' + uses: slackapi/slack-github-action@v1.25.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + payload: | + { + "text": "āœ… Dependabot PR #${{ steps.pr-info.outputs.pr_number }} passed checks in ${{ github.repository }}", + "username": "Dependabot Manager", + "icon_emoji": ":white_check_mark:", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":robot_face: *Dependabot PR Ready* :package:" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ steps.pr-info.outputs.pr_number }}" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n${{ steps.pr-info.outputs.pr_title }}" + }, + { + "type": "mrkdwn", + "text": "*Author*\n${{ steps.pr-info.outputs.pr_user }}" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View PR", + "emoji": true + }, + "url": "${{ steps.pr-info.outputs.pr_url }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Merge PR", + "emoji": true + }, + "url": "${{ steps.pr-info.outputs.pr_url }}?quick_pull=1" + } + ] + } + ] + } - - name: Notify Slack - PR Success - if: ${{ github.event.check_suite.conclusion == 'success' }} + notify_closed: + if: github.actor == 'dependabot[bot]' && github.event.action == 'closed' + runs-on: ubuntu-latest + steps: + - name: Notify Slack about closed PR uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":white_check_mark: Dependabot PR #${{ env.PR_NUMBER }} passed all checks.", + "text": "šŸ“¦ Dependabot PR #${{ github.event.pull_request.number }} was closed in ${{ github.repository }}", + "username": "Dependabot Manager", + "icon_emoji": ":package:", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": "*Successful PR:* <${{ env.PR_URL }}|${{ env.PR_TITLE }}> passed all CI checks." + "text": ":warning: *Dependabot PR Closed*" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n${{ github.repository }}" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + } + ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title }}" } } ] From 01f2538170ae3af2c6bc63053af422a0a21e24d8 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 16:36:38 +0500 Subject: [PATCH 34/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 200 ++++++++---------------- 1 file changed, 64 insertions(+), 136 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 73c107c9..5608129d 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,96 +1,96 @@ -name: Dependabot PR Manager +name: Dependabot PR Check Manager on: - workflow_dispatch: - check_suite: + check_run: types: [completed] - status: {} - pull_request: - types: [closed] jobs: - handle_checks: - # Run only for dependabot PRs when checks complete - if: | - github.actor == 'dependabot[bot]' && - (github.event_name == 'check_suite' || github.event_name == 'status') && - github.event.check_suite.conclusion != 'skipped' + handle_dependabot_pr: + # Only run for Dependabot PRs when all checks complete + if: github.actor == 'dependabot[bot]' runs-on: ubuntu-latest steps: - - name: Get associated PRs - id: get-pr - uses: octokit/request-action@v2.x + - name: Get PR information + id: pr-info + uses: actions/github-script@v6 with: - route: GET /repos/${{ github.repository }}/commits/${{ github.sha }}/pulls - mediaType: | - { - "previews": ["groot"] + script: | + // Find all PRs associated with this commit + const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ + owner: context.repo.owner, + repo: context.repo.repo, + commit_sha: context.sha + }); + + if (prs.length === 0) { + console.log('No PR found for this commit'); + return { number: 0 }; } - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + const pr = prs[0]; + return { + number: pr.number, + title: pr.title, + url: pr.html_url, + user: pr.user.login, + state: pr.state + }; - - name: Extract PR info - id: pr-info - run: | - PR_DATA=$(echo '${{ steps.get-pr.outputs.data }}' | jq -r '.[0]') - if [ -z "$PR_DATA" ] || [ "$PR_DATA" == "null" ]; then - echo "No PR associated with this commit" - echo "pr_number=0" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "pr_number=$(echo "$PR_DATA" | jq -r '.number')" >> $GITHUB_OUTPUT - echo "pr_title=$(echo "$PR_DATA" | jq -r '.title')" >> $GITHUB_OUTPUT - echo "pr_user=$(echo "$PR_DATA" | jq -r '.user.login')" >> $GITHUB_OUTPUT - echo "pr_url=$(echo "$PR_DATA" | jq -r '.html_url')" >> $GITHUB_OUTPUT - echo "pr_state=$(echo "$PR_DATA" | jq -r '.state')" >> $GITHUB_OUTPUT + - name: Skip if no PR or not open + if: fromJson(steps.pr-info.outputs.result).number == 0 || fromJson(steps.pr-info.outputs.result).state != 'open' + run: exit 0 - - name: Determine check conclusion - id: check-conclusion + - name: Verify all checks completed successfully + id: check-status run: | - # For status events - if [ "${{ github.event_name }}" == "status" ]; then - if [ "${{ github.event.state }}" == "success" ]; then - echo "conclusion=success" >> $GITHUB_OUTPUT + # Get all check runs for this ref + checks=$(curl -s \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/check-runs") + + total_checks=$(echo "$checks" | jq -r '.total_count') + completed_checks=$(echo "$checks" | jq -r '.check_runs | map(select(.status == "completed")) | length') + failed_checks=$(echo "$checks" | jq -r '.check_runs | map(select(.conclusion == "failure")) | length') + + echo "Total checks: $total_checks" + echo "Completed checks: $completed_checks" + echo "Failed checks: $failed_checks" + + if [ "$total_checks" -gt 0 ] && [ "$completed_checks" -eq "$total_checks" ]; then + if [ "$failed_checks" -gt 0 ]; then + echo "status=failure" >> $GITHUB_OUTPUT else - echo "conclusion=failure" >> $GITHUB_OUTPUT + echo "status=success" >> $GITHUB_OUTPUT fi - # For check_suite events else - echo "conclusion=${{ github.event.check_suite.conclusion }}" >> $GITHUB_OUTPUT + echo "status=pending" >> $GITHUB_OUTPUT fi - - name: Close unsuccessful PR - if: | - steps.pr-info.outputs.pr_number != '0' && - steps.pr-info.outputs.pr_state == 'open' && - steps.check-conclusion.outputs.conclusion != 'success' + - name: Close PR if checks failed + if: steps.check-status.outputs.status == 'failure' uses: superbrothers/close-pull-request@v3 with: - comment: "Automatically closed due to unsuccessful checks" + comment: "Automatically closed due to failed checks" token: ${{ secrets.GITHUB_TOKEN }} - pull_request_number: ${{ steps.pr-info.outputs.pr_number }} + pull_request_number: ${{ fromJson(steps.pr-info.outputs.result).number }} - - name: Notify Slack for successful PR - if: | - steps.pr-info.outputs.pr_number != '0' && - steps.check-conclusion.outputs.conclusion == 'success' + - name: Notify Slack if checks passed + if: steps.check-status.outputs.status == 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "āœ… Dependabot PR #${{ steps.pr-info.outputs.pr_number }} passed checks in ${{ github.repository }}", - "username": "Dependabot Manager", - "icon_emoji": ":white_check_mark:", + "text": "āœ… Dependabot PR Ready: ${{ fromJson(steps.pr-info.outputs.result).title }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": ":robot_face: *Dependabot PR Ready* :package:" + "text": "*āœ… Dependabot Update Ready*" } }, { @@ -98,94 +98,22 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository*\n" + "text": "*PR*: <${{ fromJson(steps.pr-info.outputs.result).url }}|#${{ fromJson(steps.pr-info.outputs.result).number }}>" }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ steps.pr-info.outputs.pr_number }}" + "text": "*Title*: ${{ fromJson(steps.pr-info.outputs.result).title }}" } ] }, { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title*\n${{ steps.pr-info.outputs.pr_title }}" - }, - { - "type": "mrkdwn", - "text": "*Author*\n${{ steps.pr-info.outputs.pr_user }}" - } - ] - }, - { - "type": "actions", + "type": "context", "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "View PR", - "emoji": true - }, - "url": "${{ steps.pr-info.outputs.pr_url }}" - }, - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Merge PR", - "emoji": true - }, - "url": "${{ steps.pr-info.outputs.pr_url }}?quick_pull=1" - } - ] - } - ] - } - - notify_closed: - if: github.actor == 'dependabot[bot]' && github.event.action == 'closed' - runs-on: ubuntu-latest - steps: - - name: Notify Slack about closed PR - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - payload: | - { - "text": "šŸ“¦ Dependabot PR #${{ github.event.pull_request.number }} was closed in ${{ github.repository }}", - "username": "Dependabot Manager", - "icon_emoji": ":package:", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": ":warning: *Dependabot PR Closed*" - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n${{ github.repository }}" - }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + "text": "Submitted by: ${{ fromJson(steps.pr-info.outputs.result).user }} | Repository: ${{ github.repository }}" } ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title }}" - } } ] } From 464b973bb50ec73d83c45679c28e6212755b9665 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 16:42:25 +0500 Subject: [PATCH 35/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 111 +++++------------------- 1 file changed, 21 insertions(+), 90 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 5608129d..d427533e 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,119 +1,50 @@ -name: Dependabot PR Check Manager +name: Handle Completed Dependabot PR Checks on: - check_run: + check_suite: types: [completed] jobs: handle_dependabot_pr: - # Only run for Dependabot PRs when all checks complete - if: github.actor == 'dependabot[bot]' + if: > + github.event.check_suite.pull_requests != null && + github.event.check_suite.pull_requests[0].user.login == 'dependabot[bot]' && + github.event.check_suite.status == 'completed' runs-on: ubuntu-latest - - steps: - - name: Get PR information - id: pr-info - uses: actions/github-script@v6 - with: - script: | - // Find all PRs associated with this commit - const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ - owner: context.repo.owner, - repo: context.repo.repo, - commit_sha: context.sha - }); - - if (prs.length === 0) { - console.log('No PR found for this commit'); - return { number: 0 }; - } - - const pr = prs[0]; - return { - number: pr.number, - title: pr.title, - url: pr.html_url, - user: pr.user.login, - state: pr.state - }; - - name: Skip if no PR or not open - if: fromJson(steps.pr-info.outputs.result).number == 0 || fromJson(steps.pr-info.outputs.result).state != 'open' - run: exit 0 - - - name: Verify all checks completed successfully - id: check-status + steps: + - name: Extract PR Info + id: pr_info run: | - # Get all check runs for this ref - checks=$(curl -s \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/check-runs") - - total_checks=$(echo "$checks" | jq -r '.total_count') - completed_checks=$(echo "$checks" | jq -r '.check_runs | map(select(.status == "completed")) | length') - failed_checks=$(echo "$checks" | jq -r '.check_runs | map(select(.conclusion == "failure")) | length') - - echo "Total checks: $total_checks" - echo "Completed checks: $completed_checks" - echo "Failed checks: $failed_checks" - - if [ "$total_checks" -gt 0 ] && [ "$completed_checks" -eq "$total_checks" ]; then - if [ "$failed_checks" -gt 0 ]; then - echo "status=failure" >> $GITHUB_OUTPUT - else - echo "status=success" >> $GITHUB_OUTPUT - fi - else - echo "status=pending" >> $GITHUB_OUTPUT - fi + echo "PR_NUMBER=$(jq '.[0].number' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV + echo "PR_TITLE=$(jq -r '.[0].title' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV + echo "PR_URL=$(jq -r '.[0].html_url' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - name: Close PR if checks failed - if: steps.check-status.outputs.status == 'failure' + if: ${{ github.event.check_suite.conclusion != 'success' }} uses: superbrothers/close-pull-request@v3 with: - comment: "Automatically closed due to failed checks" - token: ${{ secrets.GITHUB_TOKEN }} - pull_request_number: ${{ fromJson(steps.pr-info.outputs.result).number }} + pull-request-number: ${{ env.PR_NUMBER }} + comment: "Closed automatically due to failed CI checks." + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack if checks passed - if: steps.check-status.outputs.status == 'success' + - name: Notify Slack - PR Success + if: ${{ github.event.check_suite.conclusion == 'success' }} uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "āœ… Dependabot PR Ready: ${{ fromJson(steps.pr-info.outputs.result).title }}", + "text": ":white_check_mark: Dependabot PR #${{ env.PR_NUMBER }} passed all checks.", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": "*āœ… Dependabot Update Ready*" + "text": "*Successful PR:* <${{ env.PR_URL }}|${{ env.PR_TITLE }}> passed all CI checks." } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*PR*: <${{ fromJson(steps.pr-info.outputs.result).url }}|#${{ fromJson(steps.pr-info.outputs.result).number }}>" - }, - { - "type": "mrkdwn", - "text": "*Title*: ${{ fromJson(steps.pr-info.outputs.result).title }}" - } - ] - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Submitted by: ${{ fromJson(steps.pr-info.outputs.result).user }} | Repository: ${{ github.repository }}" - } - ] } ] } From 27e3af7423bd75547d88b936134077c5b7cf4433 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 16:51:04 +0500 Subject: [PATCH 36/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index d427533e..c6c798eb 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -8,7 +8,6 @@ jobs: handle_dependabot_pr: if: > github.event.check_suite.pull_requests != null && - github.event.check_suite.pull_requests[0].user.login == 'dependabot[bot]' && github.event.check_suite.status == 'completed' runs-on: ubuntu-latest From 9443422dc48edfc38b4165bdfc5200e7e14b6908 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 17:01:57 +0500 Subject: [PATCH 37/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 145 +++++++++++++++++++----- 1 file changed, 118 insertions(+), 27 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index c6c798eb..17f6a7d0 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,48 +1,139 @@ -name: Handle Completed Dependabot PR Checks - +name: Dependabot PR Manager on: - check_suite: - types: [completed] - + workflow_dispatch: + pull_request: + types: [opened, closed] jobs: - handle_dependabot_pr: - if: > - github.event.check_suite.pull_requests != null && - github.event.check_suite.status == 'completed' + notify: runs-on: ubuntu-latest - steps: - - name: Extract PR Info - id: pr_info + - name: Send PR notification + if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + payload: | + { + "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", + "username": "Dependabot Manager", + "icon_emoji": ":robot_face:", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":package: *New PR Notification* :package:" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" + }, + { + "type": "mrkdwn", + "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" + } + ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" + } + } + ] + } + monitor_checks: + if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' + runs-on: ubuntu-latest + needs: notify + steps: + - name: Wait for checks + uses: fountainhead/action-wait-for-check@v1.0.0 + id: wait-for-check + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.event.pull_request.head.sha }} + timeout-seconds: 600 + interval-seconds: 30 + - name: Check PR status + id: check-pr-status run: | - echo "PR_NUMBER=$(jq '.[0].number' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - echo "PR_TITLE=$(jq -r '.[0].title' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - echo "PR_URL=$(jq -r '.[0].html_url' <<< '${{ toJson(github.event.check_suite.pull_requests) }}')" >> $GITHUB_ENV - - - name: Close PR if checks failed - if: ${{ github.event.check_suite.conclusion != 'success' }} + if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then + echo "PR checks passed" + else + echo "PR checks failed - closing PR" + echo "should_close=true" >> $GITHUB_OUTPUT + fi + - name: Close failed PR + if: steps.check-pr-status.outputs.should_close == 'true' uses: superbrothers/close-pull-request@v3 with: - pull-request-number: ${{ env.PR_NUMBER }} - comment: "Closed automatically due to failed CI checks." - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Notify Slack - PR Success - if: ${{ github.event.check_suite.conclusion == 'success' }} + comment: "Automatically closed due to failed checks" + token: ${{ secrets.GITHUB_TOKEN }} + - name: Notify Slack about closed PR + if: steps.check-pr-status.outputs.should_close == 'true' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":white_check_mark: Dependabot PR #${{ env.PR_NUMBER }} passed all checks.", + "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "username": "Dependabot Manager", + "icon_emoji": ":warning:", "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":x: Dependabot PR Closed", + "emoji": true + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n${{ github.repository }}" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + } + ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title }}" + } + }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*Successful PR:* <${{ env.PR_URL }}|${{ env.PR_TITLE }}> passed all CI checks." + "text": "*Reason*\nAutomatically closed due to failed checks" } } ] From e505fe7cbc59506dd06179241dca45f6d6bf2afa Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 17:54:23 +0500 Subject: [PATCH 38/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 123 +++++++----------------- 1 file changed, 35 insertions(+), 88 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 17f6a7d0..a222102f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,111 +1,58 @@ name: Dependabot PR Manager + on: - workflow_dispatch: - pull_request: - types: [opened, closed] + check_suite: + types: [completed] + jobs: - notify: - runs-on: ubuntu-latest - steps: - - name: Send PR notification - if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - payload: | - { - "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", - "username": "Dependabot Manager", - "icon_emoji": ":robot_face:", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": ":package: *New PR Notification* :package:" - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" - } - ] - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" - }, - { - "type": "mrkdwn", - "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" - } - } - ] - } monitor_checks: - if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' + if: github.actor == 'dependabot[bot]' && github.event.check_suite.conclusion != 'neutral' runs-on: ubuntu-latest - needs: notify + steps: - - name: Wait for checks - uses: fountainhead/action-wait-for-check@v1.0.0 - id: wait-for-check + - name: Get associated PR + id: get_pr + uses: actions/github-script@v6 with: - token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ github.event.pull_request.head.sha }} - timeout-seconds: 600 - interval-seconds: 30 - - name: Check PR status - id: check-pr-status - run: | - if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then - echo "PR checks passed" - else - echo "PR checks failed - closing PR" - echo "should_close=true" >> $GITHUB_OUTPUT - fi - - name: Close failed PR - if: steps.check-pr-status.outputs.should_close == 'true' + script: | + const prs = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + head: context.payload.check_suite.head_branch, + state: 'open' + }); + const dependabotPR = prs.data.find(pr => pr.user.login === 'dependabot[bot]'); + if (dependabotPR) { + core.setOutput('pr_number', dependabotPR.number); + core.setOutput('pr_title', dependabotPR.title); + core.setOutput('pr_url', dependabotPR.html_url); + } + + - name: Close PR if checks failed + if: github.event.check_suite.conclusion != 'success' && steps.get_pr.outputs.pr_number != '' uses: superbrothers/close-pull-request@v3 with: + pull-request-number: ${{ steps.get_pr.outputs.pr_number }} comment: "Automatically closed due to failed checks" token: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack about closed PR - if: steps.check-pr-status.outputs.should_close == 'true' + + - name: Notify Slack if checks passed + if: github.event.check_suite.conclusion == 'success' && steps.get_pr.outputs.pr_number != '' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "text": "āœ… Dependabot PR #${{ steps.get_pr.outputs.pr_number }} passed all checks in ${{ github.repository }}", "username": "Dependabot Manager", - "icon_emoji": ":warning:", + "icon_emoji": ":white_check_mark:", "blocks": [ { "type": "header", "text": { "type": "plain_text", - "text": ":x: Dependabot PR Closed", + "text": ":white_check_mark: Dependabot PR Passed", "emoji": true } }, @@ -118,7 +65,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + "text": "*PR Number*\n#${{ steps.get_pr.outputs.pr_number }}" } ] }, @@ -126,14 +73,14 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title }}" + "text": "*Title*\n${{ steps.get_pr.outputs.pr_title }}" } }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*Reason*\nAutomatically closed due to failed checks" + "text": "*PR Link*\n<${{ steps.get_pr.outputs.pr_url }}|View PR>" } } ] From ff28dbff74e82ec7b486702b53515c9547f7bcee Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Mon, 26 May 2025 17:57:28 +0500 Subject: [PATCH 39/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index a222102f..af4ae376 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -6,7 +6,7 @@ on: jobs: monitor_checks: - if: github.actor == 'dependabot[bot]' && github.event.check_suite.conclusion != 'neutral' + if: github.event.action == 'completed' && github.event.check_suite.conclusion != 'neutral' runs-on: ubuntu-latest steps: From 4c09c126a2a5a54b374e9dea9d5dc8f816cb96a8 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:23:45 +0500 Subject: [PATCH 40/66] Create run-checks.yml --- .github/workflows/run-checks.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/run-checks.yml diff --git a/.github/workflows/run-checks.yml b/.github/workflows/run-checks.yml new file mode 100644 index 00000000..f21e22c1 --- /dev/null +++ b/.github/workflows/run-checks.yml @@ -0,0 +1,15 @@ +name: Run Checks + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run tests + run: echo "āœ… Simulating test suite..." From 9693b1ceb973b8fb8c399cef9328d152e253aee0 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:23:51 +0500 Subject: [PATCH 41/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 56 ++++++++++++++----------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index af4ae376..20bca924 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,16 +1,19 @@ -name: Dependabot PR Manager +# .github/workflows/notify-or-close.yml + +name: Notify or Close PR After CI on: - check_suite: - types: [completed] + workflow_run: + workflows: ["CI"] # Must match the exact name of the CI workflow + types: + - completed jobs: - monitor_checks: - if: github.event.action == 'completed' && github.event.check_suite.conclusion != 'neutral' + handle_result: runs-on: ubuntu-latest steps: - - name: Get associated PR + - name: Get PR for workflow_run SHA id: get_pr uses: actions/github-script@v6 with: @@ -18,41 +21,46 @@ jobs: const prs = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, - head: context.payload.check_suite.head_branch, state: 'open' }); - const dependabotPR = prs.data.find(pr => pr.user.login === 'dependabot[bot]'); - if (dependabotPR) { - core.setOutput('pr_number', dependabotPR.number); - core.setOutput('pr_title', dependabotPR.title); - core.setOutput('pr_url', dependabotPR.html_url); + + const pr = prs.data.find(pr => pr.head.sha === "${{ github.event.workflow_run.head_commit.id }}"); + if (pr) { + core.setOutput("pr_number", pr.number); + core.setOutput("pr_title", pr.title); + core.setOutput("pr_url", pr.html_url); + core.setOutput("is_dependabot", pr.user.login === "dependabot[bot]"); } - - name: Close PR if checks failed - if: github.event.check_suite.conclusion != 'success' && steps.get_pr.outputs.pr_number != '' + - name: Close PR if failed (even your own test PRs) + if: steps.get_pr.outputs.pr_number != '' && github.event.workflow_run.conclusion != 'success' uses: superbrothers/close-pull-request@v3 with: pull-request-number: ${{ steps.get_pr.outputs.pr_number }} - comment: "Automatically closed due to failed checks" + comment: "āŒ Automatically closed because CI checks failed." token: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack if checks passed - if: github.event.check_suite.conclusion == 'success' && steps.get_pr.outputs.pr_number != '' + - name: Notify Slack if CI passed + if: steps.get_pr.outputs.pr_number != '' && github.event.workflow_run.conclusion == 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + PR_NUMBER: ${{ steps.get_pr.outputs.pr_number }} + PR_TITLE: ${{ steps.get_pr.outputs.pr_title }} + PR_URL: ${{ steps.get_pr.outputs.pr_url }} + REPOSITORY: ${{ github.repository }} with: payload: | { - "text": "āœ… Dependabot PR #${{ steps.get_pr.outputs.pr_number }} passed all checks in ${{ github.repository }}", - "username": "Dependabot Manager", + "text": "āœ… PR #${PR_NUMBER} passed CI in ${REPOSITORY}", + "username": "PR Notifier", "icon_emoji": ":white_check_mark:", "blocks": [ { "type": "header", "text": { "type": "plain_text", - "text": ":white_check_mark: Dependabot PR Passed", + "text": ":rocket: CI Passed for PR", "emoji": true } }, @@ -61,11 +69,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository*\n${{ github.repository }}" + "text": "*Repository:*\n${REPOSITORY}" }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ steps.get_pr.outputs.pr_number }}" + "text": "*PR Number:*\n#${PR_NUMBER}" } ] }, @@ -73,14 +81,14 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Title*\n${{ steps.get_pr.outputs.pr_title }}" + "text": "*Title:*\n${PR_TITLE}" } }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link*\n<${{ steps.get_pr.outputs.pr_url }}|View PR>" + "text": "*PR Link:*\n<${PR_URL}|View PR>" } } ] From 1c2a71be360cfd86dc0c09acdd1819497a47dcbb Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:45:30 +0500 Subject: [PATCH 42/66] Delete .github/workflows/run-checks.yml --- .github/workflows/run-checks.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/workflows/run-checks.yml diff --git a/.github/workflows/run-checks.yml b/.github/workflows/run-checks.yml deleted file mode 100644 index f21e22c1..00000000 --- a/.github/workflows/run-checks.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Run Checks - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Run tests - run: echo "āœ… Simulating test suite..." From 3596a510aeedcb62a5ef834fe04313e3835f3051 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:45:56 +0500 Subject: [PATCH 43/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 90 ++++++------------------- 1 file changed, 21 insertions(+), 69 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 20bca924..7caa6def 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,95 +1,47 @@ -# .github/workflows/notify-or-close.yml - -name: Notify or Close PR After CI +name: Notify on PR Open on: - workflow_run: - workflows: ["CI"] # Must match the exact name of the CI workflow - types: - - completed + pull_request: + types: [opened] jobs: - handle_result: + slack-notify: runs-on: ubuntu-latest steps: - - name: Get PR for workflow_run SHA - id: get_pr - uses: actions/github-script@v6 - with: - script: | - const prs = await github.rest.pulls.list({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open' - }); - - const pr = prs.data.find(pr => pr.head.sha === "${{ github.event.workflow_run.head_commit.id }}"); - if (pr) { - core.setOutput("pr_number", pr.number); - core.setOutput("pr_title", pr.title); - core.setOutput("pr_url", pr.html_url); - core.setOutput("is_dependabot", pr.user.login === "dependabot[bot]"); - } - - - name: Close PR if failed (even your own test PRs) - if: steps.get_pr.outputs.pr_number != '' && github.event.workflow_run.conclusion != 'success' - uses: superbrothers/close-pull-request@v3 - with: - pull-request-number: ${{ steps.get_pr.outputs.pr_number }} - comment: "āŒ Automatically closed because CI checks failed." - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Notify Slack if CI passed - if: steps.get_pr.outputs.pr_number != '' && github.event.workflow_run.conclusion == 'success' + - name: Send Slack notification uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - PR_NUMBER: ${{ steps.get_pr.outputs.pr_number }} - PR_TITLE: ${{ steps.get_pr.outputs.pr_title }} - PR_URL: ${{ steps.get_pr.outputs.pr_url }} - REPOSITORY: ${{ github.repository }} with: payload: | { - "text": "āœ… PR #${PR_NUMBER} passed CI in ${REPOSITORY}", + "text": "šŸ“¢ New PR opened in ${{ github.repository }}", "username": "PR Notifier", - "icon_emoji": ":white_check_mark:", + "icon_emoji": ":bell:", "blocks": [ { - "type": "header", + "type": "section", "text": { - "type": "plain_text", - "text": ":rocket: CI Passed for PR", - "emoji": true + "type": "mrkdwn", + "text": "*<${{ + github.event.pull_request.html_url + }}|New PR opened in ${{ github.repository }}>*\n*Title:* ${{ github.event.pull_request.title }}\n*Number:* #${{ github.event.pull_request.number }}\n*Author:* <${{ github.event.pull_request.user.html_url }}|@${{ github.event.pull_request.user.login }}>" } }, { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository:*\n${REPOSITORY}" - }, + "type": "actions", + "elements": [ { - "type": "mrkdwn", - "text": "*PR Number:*\n#${PR_NUMBER}" + "type": "button", + "text": { + "type": "plain_text", + "text": "View PR", + "emoji": true + }, + "url": "${{ github.event.pull_request.html_url }}" } ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Title:*\n${PR_TITLE}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Link:*\n<${PR_URL}|View PR>" - } } ] } From 16e2d79b88177b721859c51631de7b0688bd3405 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:54:21 +0500 Subject: [PATCH 44/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 51 ++++++++++++++++++++----- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7caa6def..bddca493 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,34 +1,65 @@ -name: Notify on PR Open +name: Dependabot PR Notifier on: + workflow_dispatch: pull_request: types: [opened] jobs: - slack-notify: + notify: runs-on: ubuntu-latest - steps: - - name: Send Slack notification + - name: Send PR notification uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "šŸ“¢ New PR opened in ${{ github.repository }}", - "username": "PR Notifier", - "icon_emoji": ":bell:", + "username": "Dependabot Manager", + "icon_emoji": ":robot_face:", "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "šŸ“¦ New ${{ github.actor == 'dependabot[bot]' ? 'Dependabot' : '' }} PR", + "emoji": true + } + }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*<${{ - github.event.pull_request.html_url - }}|New PR opened in ${{ github.repository }}>*\n*Title:* ${{ github.event.pull_request.title }}\n*Number:* #${{ github.event.pull_request.number }}\n*Author:* <${{ github.event.pull_request.user.html_url }}|@${{ github.event.pull_request.user.login }}>" + "text": "*<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>*" } }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Author*\n@${{ github.event.pull_request.user.login }}" + }, + { + "type": "mrkdwn", + "text": "*Type*\n${{ github.actor == 'dependabot[bot]' ? 'Dependency Update' : 'Regular PR' }}" + } + ] + }, { "type": "actions", "elements": [ From 8a4203611a2f212d13b09e4696ca30b68be61e1e Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:56:37 +0500 Subject: [PATCH 45/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index bddca493..9b4a6145 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -9,6 +9,15 @@ jobs: notify: runs-on: ubuntu-latest steps: + - name: Determine PR type + id: pr-type + run: | + if [ "${{ github.actor }}" = "dependabot[bot]" ]; then + echo "pr_type=Dependabot" >> $GITHUB_ENV + else + echo "pr_type=Regular" >> $GITHUB_ENV + fi + - name: Send PR notification uses: slackapi/slack-github-action@v1.25.0 env: @@ -16,14 +25,14 @@ jobs: with: payload: | { - "username": "Dependabot Manager", + "username": "PR Manager", "icon_emoji": ":robot_face:", "blocks": [ { "type": "header", "text": { "type": "plain_text", - "text": "šŸ“¦ New ${{ github.actor == 'dependabot[bot]' ? 'Dependabot' : '' }} PR", + "text": "šŸ“¦ New ${{ env.pr_type }} PR", "emoji": true } }, @@ -56,7 +65,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*Type*\n${{ github.actor == 'dependabot[bot]' ? 'Dependency Update' : 'Regular PR' }}" + "text": "*Type*\n${{ env.pr_type }} PR" } ] }, From 0e958056c5b7a33cb148d00f6cefe91be7f2fbd6 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 09:59:56 +0500 Subject: [PATCH 46/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 9b4a6145..122561cf 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -9,16 +9,23 @@ jobs: notify: runs-on: ubuntu-latest steps: - - name: Determine PR type - id: pr-type + - name: Prepare PR data + id: prepare run: | - if [ "${{ github.actor }}" = "dependabot[bot]" ]; then - echo "pr_type=Dependabot" >> $GITHUB_ENV - else - echo "pr_type=Regular" >> $GITHUB_ENV - fi + # Set default values if PR data isn't available (workflow_dispatch case) + PR_TITLE="${GITHUB_EVENT_NAME == 'workflow_dispatch' && 'Manual workflow trigger' || '${{ github.event.pull_request.title }}'}" + PR_NUMBER="${GITHUB_EVENT_NAME == 'workflow_dispatch' && 'N/A' || '${{ github.event.pull_request.number }}'}" + PR_AUTHOR="${GITHUB_EVENT_NAME == 'workflow_dispatch' && '${{ github.actor }}' || '${{ github.event.pull_request.user.login }}'}" + PR_URL="${GITHUB_EVENT_NAME == 'workflow_dispatch' && 'https://github.com/${{ github.repository }}/pulls' || '${{ github.event.pull_request.html_url }}'}" + PR_TYPE="${{ github.actor == 'dependabot[bot]' && 'Dependabot' || 'Regular' }}" + + echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV + echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV + echo "PR_AUTHOR=${PR_AUTHOR}" >> $GITHUB_ENV + echo "PR_URL=${PR_URL}" >> $GITHUB_ENV + echo "PR_TYPE=${PR_TYPE}" >> $GITHUB_ENV - - name: Send PR notification + - name: Send Slack notification uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} @@ -32,7 +39,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "šŸ“¦ New ${{ env.pr_type }} PR", + "text": "šŸ“¦ New ${{ env.PR_TYPE }} PR", "emoji": true } }, @@ -40,7 +47,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>*" + "text": "*<${{ env.PR_URL }}|${{ env.PR_TITLE }}>*" } }, { @@ -52,7 +59,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + "text": "*PR Number*\n#${{ env.PR_NUMBER }}" } ] }, @@ -61,11 +68,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Author*\n@${{ github.event.pull_request.user.login }}" + "text": "*Author*\n@${{ env.PR_AUTHOR }}" }, { "type": "mrkdwn", - "text": "*Type*\n${{ env.pr_type }} PR" + "text": "*Type*\n${{ env.PR_TYPE }} PR" } ] }, @@ -79,7 +86,7 @@ jobs: "text": "View PR", "emoji": true }, - "url": "${{ github.event.pull_request.html_url }}" + "url": "${{ env.PR_URL }}" } ] } From d0471a1c8b8b82bb9776022269ddd86ecd555bed Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:01:15 +0500 Subject: [PATCH 47/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 132 ++++++++++++++++-------- 1 file changed, 89 insertions(+), 43 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 122561cf..17f6a7d0 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,53 +1,29 @@ -name: Dependabot PR Notifier - +name: Dependabot PR Manager on: workflow_dispatch: pull_request: - types: [opened] - + types: [opened, closed] jobs: notify: runs-on: ubuntu-latest steps: - - name: Prepare PR data - id: prepare - run: | - # Set default values if PR data isn't available (workflow_dispatch case) - PR_TITLE="${GITHUB_EVENT_NAME == 'workflow_dispatch' && 'Manual workflow trigger' || '${{ github.event.pull_request.title }}'}" - PR_NUMBER="${GITHUB_EVENT_NAME == 'workflow_dispatch' && 'N/A' || '${{ github.event.pull_request.number }}'}" - PR_AUTHOR="${GITHUB_EVENT_NAME == 'workflow_dispatch' && '${{ github.actor }}' || '${{ github.event.pull_request.user.login }}'}" - PR_URL="${GITHUB_EVENT_NAME == 'workflow_dispatch' && 'https://github.com/${{ github.repository }}/pulls' || '${{ github.event.pull_request.html_url }}'}" - PR_TYPE="${{ github.actor == 'dependabot[bot]' && 'Dependabot' || 'Regular' }}" - - echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV - echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV - echo "PR_AUTHOR=${PR_AUTHOR}" >> $GITHUB_ENV - echo "PR_URL=${PR_URL}" >> $GITHUB_ENV - echo "PR_TYPE=${PR_TYPE}" >> $GITHUB_ENV - - - name: Send Slack notification + - name: Send PR notification + if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "username": "PR Manager", + "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", + "username": "Dependabot Manager", "icon_emoji": ":robot_face:", "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "šŸ“¦ New ${{ env.PR_TYPE }} PR", - "emoji": true - } - }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*<${{ env.PR_URL }}|${{ env.PR_TITLE }}>*" + "text": ":package: *New PR Notification* :package:" } }, { @@ -59,7 +35,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ env.PR_NUMBER }}" + "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" } ] }, @@ -68,27 +44,97 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Author*\n@${{ env.PR_AUTHOR }}" + "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" }, { "type": "mrkdwn", - "text": "*Type*\n${{ env.PR_TYPE }} PR" + "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" } ] }, { - "type": "actions", - "elements": [ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" + } + } + ] + } + monitor_checks: + if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' + runs-on: ubuntu-latest + needs: notify + steps: + - name: Wait for checks + uses: fountainhead/action-wait-for-check@v1.0.0 + id: wait-for-check + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.event.pull_request.head.sha }} + timeout-seconds: 600 + interval-seconds: 30 + - name: Check PR status + id: check-pr-status + run: | + if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then + echo "PR checks passed" + else + echo "PR checks failed - closing PR" + echo "should_close=true" >> $GITHUB_OUTPUT + fi + - name: Close failed PR + if: steps.check-pr-status.outputs.should_close == 'true' + uses: superbrothers/close-pull-request@v3 + with: + comment: "Automatically closed due to failed checks" + token: ${{ secrets.GITHUB_TOKEN }} + - name: Notify Slack about closed PR + if: steps.check-pr-status.outputs.should_close == 'true' + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + payload: | + { + "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "username": "Dependabot Manager", + "icon_emoji": ":warning:", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":x: Dependabot PR Closed", + "emoji": true + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n${{ github.repository }}" + }, { - "type": "button", - "text": { - "type": "plain_text", - "text": "View PR", - "emoji": true - }, - "url": "${{ env.PR_URL }}" + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" } ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title }}" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Reason*\nAutomatically closed due to failed checks" + } } ] } From eb56c46d7c2ec22e6c3605d04b6e4ed553c13a81 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:04:17 +0500 Subject: [PATCH 48/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 43 ++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 17f6a7d0..012446cc 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -15,15 +15,16 @@ jobs: with: payload: | { - "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", + "text": "*New PR Notification!*", "username": "Dependabot Manager", "icon_emoji": ":robot_face:", "blocks": [ { - "type": "section", + "type": "header", "text": { - "type": "mrkdwn", - "text": ":package: *New PR Notification* :package:" + "type": "plain_text", + "text": ":package: New Pull Request :package:", + "emoji": true } }, { @@ -31,11 +32,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository*\n" + "text": "*Repository:*\n" }, { "type": "mrkdwn", - "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" + "text": "*PR Number:*\n${{ github.event.pull_request.number || 'N/A' }}" } ] }, @@ -44,11 +45,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" + "text": "*Title:*\n${{ github.event.pull_request.title || 'Manual trigger' }}" }, { "type": "mrkdwn", - "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" + "text": "*Author:*\n${{ github.event.pull_request.user.login || github.actor }}" } ] }, @@ -56,7 +57,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" + "text": "*PR Link:*\n<${{ github.event.pull_request.html_url }}|View PR>" } } ] @@ -97,7 +98,7 @@ jobs: with: payload: | { - "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "text": ":x: *Dependabot PR Closed*", "username": "Dependabot Manager", "icon_emoji": ":warning:", "blocks": [ @@ -105,7 +106,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": ":x: Dependabot PR Closed", + "text": ":x: PR Closed Due to Failed Checks", "emoji": true } }, @@ -114,26 +115,32 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository*\n${{ github.repository }}" + "text": "*Repository:*\n" }, { "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + "text": "*PR Number:*\n#${{ github.event.pull_request.number }}" } ] }, { "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title }}" - } + "fields": [ + { + "type": "mrkdwn", + "text": "*Title:*\n${{ github.event.pull_request.title }}" + }, + { + "type": "mrkdwn", + "text": "*Status:*\nAutomatically closed due to failed checks" + } + ] }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*Reason*\nAutomatically closed due to failed checks" + "text": "*PR Link:*\n<${{ github.event.pull_request.html_url }}|View PR>" } } ] From b138aaf1da24afee92d90e85e6fdb7103a1b8527 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:07:29 +0500 Subject: [PATCH 49/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 43 +++++++++++-------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 012446cc..17f6a7d0 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -15,16 +15,15 @@ jobs: with: payload: | { - "text": "*New PR Notification!*", + "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", "username": "Dependabot Manager", "icon_emoji": ":robot_face:", "blocks": [ { - "type": "header", + "type": "section", "text": { - "type": "plain_text", - "text": ":package: New Pull Request :package:", - "emoji": true + "type": "mrkdwn", + "text": ":package: *New PR Notification* :package:" } }, { @@ -32,11 +31,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository:*\n" + "text": "*Repository*\n" }, { "type": "mrkdwn", - "text": "*PR Number:*\n${{ github.event.pull_request.number || 'N/A' }}" + "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" } ] }, @@ -45,11 +44,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Title:*\n${{ github.event.pull_request.title || 'Manual trigger' }}" + "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" }, { "type": "mrkdwn", - "text": "*Author:*\n${{ github.event.pull_request.user.login || github.actor }}" + "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" } ] }, @@ -57,7 +56,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link:*\n<${{ github.event.pull_request.html_url }}|View PR>" + "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" } } ] @@ -98,7 +97,7 @@ jobs: with: payload: | { - "text": ":x: *Dependabot PR Closed*", + "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", "username": "Dependabot Manager", "icon_emoji": ":warning:", "blocks": [ @@ -106,7 +105,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": ":x: PR Closed Due to Failed Checks", + "text": ":x: Dependabot PR Closed", "emoji": true } }, @@ -115,32 +114,26 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Repository:*\n" + "text": "*Repository*\n${{ github.repository }}" }, { "type": "mrkdwn", - "text": "*PR Number:*\n#${{ github.event.pull_request.number }}" + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" } ] }, { "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title:*\n${{ github.event.pull_request.title }}" - }, - { - "type": "mrkdwn", - "text": "*Status:*\nAutomatically closed due to failed checks" - } - ] + "text": { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title }}" + } }, { "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link:*\n<${{ github.event.pull_request.html_url }}|View PR>" + "text": "*Reason*\nAutomatically closed due to failed checks" } } ] From e970d4bd0ad2be3835a21d72958f644c29335810 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:15:01 +0500 Subject: [PATCH 50/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 17f6a7d0..2c10e4f7 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,12 +1,23 @@ name: Dependabot PR Manager + on: workflow_dispatch: pull_request: types: [opened, closed] + jobs: notify: runs-on: ubuntu-latest steps: + - name: Prepare PR Link + id: prepare-link + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "PR_LINK=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV + else + echo "PR_LINK=https://github.com/${{ github.repository }}/pulls" >> $GITHUB_ENV + fi + - name: Send PR notification if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' uses: slackapi/slack-github-action@v1.25.0 @@ -15,7 +26,7 @@ jobs: with: payload: | { - "text": "New PR Notification for ${{ github.repository }} - ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.event.pull_request.user.login || github.actor }}", + "text": "šŸ“¦ New PR in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title || 'Manual trigger' }}\nAuthor: ${{ github.event.pull_request.user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", "username": "Dependabot Manager", "icon_emoji": ":robot_face:", "blocks": [ @@ -56,11 +67,12 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*PR Link*\n<${{ github.event.pull_request.html_url || format('https://github.com/{0}/pulls', github.repository) }}|View PR>" + "text": "*PR Link*\n<${{ env.PR_LINK }}|View PR>" } } ] } + monitor_checks: if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' runs-on: ubuntu-latest @@ -97,7 +109,7 @@ jobs: with: payload: | { - "text": "Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks in ${{ github.repository }}", + "text": "āŒ Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks\nRepository: ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title }}\nLink: ${{ github.event.pull_request.html_url }}", "username": "Dependabot Manager", "icon_emoji": ":warning:", "blocks": [ @@ -135,6 +147,13 @@ jobs: "type": "mrkdwn", "text": "*Reason*\nAutomatically closed due to failed checks" } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR Link*\n<${{ github.event.pull_request.html_url }}|View Closed PR>" + } } ] } From ca108b623360abd87943326aca083efa016631c8 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:29:55 +0500 Subject: [PATCH 51/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 126 ++---------------------- 1 file changed, 6 insertions(+), 120 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 2c10e4f7..7d6577d4 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,4 +1,4 @@ -name: Dependabot PR Manager +name: Dependabot PR Notifier on: workflow_dispatch: @@ -28,132 +28,18 @@ jobs: { "text": "šŸ“¦ New PR in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title || 'Manual trigger' }}\nAuthor: ${{ github.event.pull_request.user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", "username": "Dependabot Manager", - "icon_emoji": ":robot_face:", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": ":package: *New PR Notification* :package:" - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" - } - ] - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" - }, - { - "type": "mrkdwn", - "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Link*\n<${{ env.PR_LINK }}|View PR>" - } - } - ] + "icon_emoji": ":robot_face:" } - monitor_checks: - if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' - runs-on: ubuntu-latest - needs: notify - steps: - - name: Wait for checks - uses: fountainhead/action-wait-for-check@v1.0.0 - id: wait-for-check - with: - token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ github.event.pull_request.head.sha }} - timeout-seconds: 600 - interval-seconds: 30 - - name: Check PR status - id: check-pr-status - run: | - if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then - echo "PR checks passed" - else - echo "PR checks failed - closing PR" - echo "should_close=true" >> $GITHUB_OUTPUT - fi - - name: Close failed PR - if: steps.check-pr-status.outputs.should_close == 'true' - uses: superbrothers/close-pull-request@v3 - with: - comment: "Automatically closed due to failed checks" - token: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack about closed PR - if: steps.check-pr-status.outputs.should_close == 'true' + - name: Send closed PR notification + if: github.event.action == 'closed' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "āŒ Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks\nRepository: ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title }}\nLink: ${{ github.event.pull_request.html_url }}", + "text": "āŒ PR Closed in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title }}\nAuthor: ${{ github.event.pull_request.user.login }}\nLink: ${{ github.event.pull_request.html_url }}\nStatus: ${{ github.event.pull_request.merged ? 'Merged' : 'Closed without merge' }}", "username": "Dependabot Manager", - "icon_emoji": ":warning:", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": ":x: Dependabot PR Closed", - "emoji": true - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n${{ github.repository }}" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Reason*\nAutomatically closed due to failed checks" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Link*\n<${{ github.event.pull_request.html_url }}|View Closed PR>" - } - } - ] + "icon_emoji": ":warning:" } From 40ce35cd49be503342258f0076a18c4053d245c8 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:32:52 +0500 Subject: [PATCH 52/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 132 ++++++++++++++++++++++-- 1 file changed, 121 insertions(+), 11 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7d6577d4..bcb6ceeb 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,10 +1,8 @@ -name: Dependabot PR Notifier - +name: Dependabot PR Manager on: workflow_dispatch: pull_request: types: [opened, closed] - jobs: notify: runs-on: ubuntu-latest @@ -17,7 +15,6 @@ jobs: else echo "PR_LINK=https://github.com/${{ github.repository }}/pulls" >> $GITHUB_ENV fi - - name: Send PR notification if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' uses: slackapi/slack-github-action@v1.25.0 @@ -26,20 +23,133 @@ jobs: with: payload: | { - "text": "šŸ“¦ New PR in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title || 'Manual trigger' }}\nAuthor: ${{ github.event.pull_request.user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", + "text": ":package: New PR in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title || 'Manual trigger' }}\nAuthor: ${{ github.event.pull_request.user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", "username": "Dependabot Manager", - "icon_emoji": ":robot_face:" + "icon_emoji": ":robot_face:", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":package: *New PR Notification* :package:" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" + }, + { + "type": "mrkdwn", + "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" + } + ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR Link*\n<${{ env.PR_LINK }}|View PR>" + } + } + ] } - - - name: Send closed PR notification - if: github.event.action == 'closed' + monitor_checks: + if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' + runs-on: ubuntu-latest + needs: notify + steps: + - name: Wait for checks + uses: fountainhead/action-wait-for-check@v1.0.0 + id: wait-for-check + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.event.pull_request.head.sha }} + timeout-seconds: 600 + interval-seconds: 30 + - name: Check PR status + id: check-pr-status + run: | + if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then + echo "PR checks passed" + else + echo "PR checks failed - closing PR" + echo "should_close=true" >> $GITHUB_OUTPUT + fi + - name: Close failed PR + if: steps.check-pr-status.outputs.should_close == 'true' + uses: superbrothers/close-pull-request@v3 + with: + comment: "Automatically closed due to failed checks" + token: ${{ secrets.GITHUB_TOKEN }} + - name: Notify Slack about closed PR + if: steps.check-pr-status.outputs.should_close == 'true' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": "āŒ PR Closed in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title }}\nAuthor: ${{ github.event.pull_request.user.login }}\nLink: ${{ github.event.pull_request.html_url }}\nStatus: ${{ github.event.pull_request.merged ? 'Merged' : 'Closed without merge' }}", + "text": ":x: Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks\nRepository: ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title }}\nLink: ${{ github.event.pull_request.html_url }}", "username": "Dependabot Manager", - "icon_emoji": ":warning:" + "icon_emoji": ":warning:", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":x: Dependabot PR Closed", + "emoji": true + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository*\n${{ github.repository }}" + }, + { + "type": "mrkdwn", + "text": "*PR Number*\n#${{ github.event.pull_request.number }}" + } + ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Title*\n${{ github.event.pull_request.title }}" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Reason*\nAutomatically closed due to failed checks" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*PR Link*\n<${{ github.event.pull_request.html_url }}|View Closed PR>" + } + } + ] } From 58c714245378b60a16c95750ff62077d8f1a7b78 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 10:36:29 +0500 Subject: [PATCH 53/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 128 +----------------------- 1 file changed, 1 insertion(+), 127 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index bcb6ceeb..60036ed8 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -25,131 +25,5 @@ jobs: { "text": ":package: New PR in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title || 'Manual trigger' }}\nAuthor: ${{ github.event.pull_request.user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", "username": "Dependabot Manager", - "icon_emoji": ":robot_face:", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": ":package: *New PR Notification* :package:" - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n${{ github.event.pull_request.number || 'N/A' }}" - } - ] - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title || 'Manual workflow trigger' }}" - }, - { - "type": "mrkdwn", - "text": "*Author*\n${{ github.event.pull_request.user.login || github.actor }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Link*\n<${{ env.PR_LINK }}|View PR>" - } - } - ] - } - monitor_checks: - if: github.actor == 'dependabot[bot]' && github.event.action == 'opened' - runs-on: ubuntu-latest - needs: notify - steps: - - name: Wait for checks - uses: fountainhead/action-wait-for-check@v1.0.0 - id: wait-for-check - with: - token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ github.event.pull_request.head.sha }} - timeout-seconds: 600 - interval-seconds: 30 - - name: Check PR status - id: check-pr-status - run: | - if [[ "${{ steps.wait-for-check.outputs.conclusion }}" == "success" ]]; then - echo "PR checks passed" - else - echo "PR checks failed - closing PR" - echo "should_close=true" >> $GITHUB_OUTPUT - fi - - name: Close failed PR - if: steps.check-pr-status.outputs.should_close == 'true' - uses: superbrothers/close-pull-request@v3 - with: - comment: "Automatically closed due to failed checks" - token: ${{ secrets.GITHUB_TOKEN }} - - name: Notify Slack about closed PR - if: steps.check-pr-status.outputs.should_close == 'true' - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - payload: | - { - "text": ":x: Dependabot PR #${{ github.event.pull_request.number }} was closed due to failed checks\nRepository: ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title }}\nLink: ${{ github.event.pull_request.html_url }}", - "username": "Dependabot Manager", - "icon_emoji": ":warning:", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": ":x: Dependabot PR Closed", - "emoji": true - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Repository*\n${{ github.repository }}" - }, - { - "type": "mrkdwn", - "text": "*PR Number*\n#${{ github.event.pull_request.number }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Title*\n${{ github.event.pull_request.title }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Reason*\nAutomatically closed due to failed checks" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Link*\n<${{ github.event.pull_request.html_url }}|View Closed PR>" - } - } - ] + "icon_emoji": ":robot_face:" } From 14575e24b994d7d7c6e9eb39ba4309190244897f Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 11:09:46 +0500 Subject: [PATCH 54/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 35 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 60036ed8..7e1bd51f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,29 +1,44 @@ -name: Dependabot PR Manager +name: PR Checks Completed Notification + on: - workflow_dispatch: - pull_request: - types: [opened, closed] + check_suite: + types: [completed] + jobs: - notify: + notify-checks: runs-on: ubuntu-latest steps: - name: Prepare PR Link id: prepare-link run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - echo "PR_LINK=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV + if [ "${{ github.event.check_suite.pull_requests[0].html_url }}" != "" ]; then + echo "PR_LINK=${{ github.event.check_suite.pull_requests[0].html_url }}" >> $GITHUB_ENV else echo "PR_LINK=https://github.com/${{ github.repository }}/pulls" >> $GITHUB_ENV fi - - name: Send PR notification - if: github.event.action == 'opened' || github.event_name == 'workflow_dispatch' + + - name: Send Slack Notification for Success + if: github.event.check_suite.conclusion == 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":package: New PR in ${{ github.repository }}\nTitle: ${{ github.event.pull_request.title || 'Manual trigger' }}\nAuthor: ${{ github.event.pull_request.user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", + "text": ":white_check_mark: PR checks passed in ${{ github.repository }}\nTitle: ${{ github.event.check_suite.pull_requests[0].title || 'Unknown' }}\nAuthor: ${{ github.event.check_suite.pull_requests[0].user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", + "username": "Dependabot Manager", + "icon_emoji": ":robot_face:" + } + + - name: Send Slack Notification for Failure + if: github.event.check_suite.conclusion == 'failure' + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + payload: | + { + "text": ":x: PR checks failed in ${{ github.repository }}\nTitle: ${{ github.event.check_suite.pull_requests[0].title || 'Unknown' }}\nAuthor: ${{ github.event.check_suite.pull_requests[0].user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", "username": "Dependabot Manager", "icon_emoji": ":robot_face:" } From ce69cab86eb7b3588a49bcdc9a8c3a5a71faa13f Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 12:01:31 +0500 Subject: [PATCH 55/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7e1bd51f..7372a6e4 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,7 +1,7 @@ name: PR Checks Completed Notification on: - check_suite: + status: types: [completed] jobs: From 8bbd44e05822090bf18a9b130e42f7ca5635d6ac Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 12:13:09 +0500 Subject: [PATCH 56/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7372a6e4..7e1bd51f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,7 +1,7 @@ name: PR Checks Completed Notification on: - status: + check_suite: types: [completed] jobs: From ea8276cab67780eaf41d2917c4e418075a1eff3a Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 12:16:40 +0500 Subject: [PATCH 57/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7e1bd51f..7372a6e4 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,7 +1,7 @@ name: PR Checks Completed Notification on: - check_suite: + status: types: [completed] jobs: From 6749d8a18e5c4e1ebc936142ee5ffa20eaf4f0d9 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 12:24:31 +0500 Subject: [PATCH 58/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7372a6e4..7e1bd51f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,7 +1,7 @@ name: PR Checks Completed Notification on: - status: + check_suite: types: [completed] jobs: From 6a32c3bb20cdacab1f1dc7ce513a3727ddbb7fbb Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 12:39:50 +0500 Subject: [PATCH 59/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7e1bd51f..e70f06e1 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,6 +1,7 @@ name: PR Checks Completed Notification on: + workflow_dispatch: check_suite: types: [completed] From 22c62758deb042952b3d52512dad50bcfd2da4b6 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 12:41:46 +0500 Subject: [PATCH 60/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index e70f06e1..7e1bd51f 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,7 +1,6 @@ name: PR Checks Completed Notification on: - workflow_dispatch: check_suite: types: [completed] From 4794c5a2fc9a31185af5e789d1f62fa03bbb34ff Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 13:06:30 +0500 Subject: [PATCH 61/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 7e1bd51f..ef2a458c 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -8,6 +8,15 @@ jobs: notify-checks: runs-on: ubuntu-latest steps: + - name: Fetch PR Details + id: fetch-pr + run: | + echo "Fetching PR details..." + PR_NUMBER=${{ github.event.check_suite.pull_requests[0].number }} + PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}") + PR_TITLE=$(echo "$PR_DATA" | jq -r '.title') + echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV - name: Prepare PR Link id: prepare-link run: | From f3076285aa8d26bd813992a64698e9c511f2f694 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 13:08:52 +0500 Subject: [PATCH 62/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index ef2a458c..01308bdf 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -8,15 +8,7 @@ jobs: notify-checks: runs-on: ubuntu-latest steps: - - name: Fetch PR Details - id: fetch-pr - run: | - echo "Fetching PR details..." - PR_NUMBER=${{ github.event.check_suite.pull_requests[0].number }} - PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}") - PR_TITLE=$(echo "$PR_DATA" | jq -r '.title') - echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV + - name: Prepare PR Link id: prepare-link run: | From 604d78b1d1a6d14c4a0e5ce14fe966c851da08ff Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 14:30:05 +0500 Subject: [PATCH 63/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 68 ++++++++++++++++++------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 01308bdf..0ac3d21d 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,45 +1,79 @@ name: PR Checks Completed Notification on: - check_suite: - types: [completed] + workflow_run: + workflows: ["*"] + types: + - completed jobs: notify-checks: runs-on: ubuntu-latest steps: - - - name: Prepare PR Link - id: prepare-link - run: | - if [ "${{ github.event.check_suite.pull_requests[0].html_url }}" != "" ]; then - echo "PR_LINK=${{ github.event.check_suite.pull_requests[0].html_url }}" >> $GITHUB_ENV - else - echo "PR_LINK=https://github.com/${{ github.repository }}/pulls" >> $GITHUB_ENV - fi + - name: Get PR Information + id: get-pr-info + uses: actions/github-script@v6 + with: + script: | + const { owner, repo } = context.repo; + const run = context.payload.workflow_run; + + // Get associated PRs + const pulls = await github.rest.pulls.list({ + owner, + repo, + state: 'open' + }); + + // Find PR associated with this commit + const pr = pulls.data.find(pr => pr.head.sha === run.head_sha); + + if (pr) { + core.exportVariable('PR_TITLE', pr.title); + core.exportVariable('PR_AUTHOR', pr.user.login); + core.exportVariable('PR_LINK', pr.html_url); + } else { + core.exportVariable('PR_TITLE', 'Unknown'); + core.exportVariable('PR_AUTHOR', context.actor); + core.exportVariable('PR_LINK', `https://github.com/${owner}/${repo}/pulls`); + } + + // Get all workflow runs for this commit + const allRuns = await github.rest.actions.listWorkflowRunsForRepo({ + owner, + repo, + head_sha: run.head_sha + }); + + // Check if all workflows are complete and successful + const isSuccess = allRuns.data.workflow_runs.every(run => + run.status === 'completed' && run.conclusion === 'success' + ); + + core.exportVariable('ALL_CHECKS_STATUS', isSuccess ? 'success' : 'failure'); - name: Send Slack Notification for Success - if: github.event.check_suite.conclusion == 'success' + if: env.ALL_CHECKS_STATUS == 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":white_check_mark: PR checks passed in ${{ github.repository }}\nTitle: ${{ github.event.check_suite.pull_requests[0].title || 'Unknown' }}\nAuthor: ${{ github.event.check_suite.pull_requests[0].user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", - "username": "Dependabot Manager", + "text": ":white_check_mark: All PR checks passed!\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}", + "username": "PR Checks Monitor", "icon_emoji": ":robot_face:" } - name: Send Slack Notification for Failure - if: github.event.check_suite.conclusion == 'failure' + if: env.ALL_CHECKS_STATUS == 'failure' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":x: PR checks failed in ${{ github.repository }}\nTitle: ${{ github.event.check_suite.pull_requests[0].title || 'Unknown' }}\nAuthor: ${{ github.event.check_suite.pull_requests[0].user.login || github.actor }}\nLink: ${{ env.PR_LINK }}", - "username": "Dependabot Manager", + "text": ":x: Some PR checks failed!\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}", + "username": "PR Checks Monitor", "icon_emoji": ":robot_face:" } From bdbf9e8cefcfe5e94db292df268f2ed3759058e7 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 14:38:19 +0500 Subject: [PATCH 64/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 74 +++++++++++++++++++------ 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 0ac3d21d..9efed065 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -18,62 +18,100 @@ jobs: const { owner, repo } = context.repo; const run = context.payload.workflow_run; - // Get associated PRs - const pulls = await github.rest.pulls.list({ + // Get PR directly from the workflow run's head SHA + const response = await github.rest.repos.listPullRequestsAssociatedWithCommit({ owner, repo, - state: 'open' + commit_sha: run.head_sha }); - // Find PR associated with this commit - const pr = pulls.data.find(pr => pr.head.sha === run.head_sha); + const pr = response.data[0]; // Get the first associated PR if (pr) { core.exportVariable('PR_TITLE', pr.title); core.exportVariable('PR_AUTHOR', pr.user.login); core.exportVariable('PR_LINK', pr.html_url); + core.exportVariable('PR_NUMBER', pr.number.toString()); } else { core.exportVariable('PR_TITLE', 'Unknown'); core.exportVariable('PR_AUTHOR', context.actor); core.exportVariable('PR_LINK', `https://github.com/${owner}/${repo}/pulls`); + core.exportVariable('PR_NUMBER', ''); } - // Get all workflow runs for this commit - const allRuns = await github.rest.actions.listWorkflowRunsForRepo({ + // Get check runs for this commit + const checkRuns = await github.rest.checks.listForRef({ owner, repo, - head_sha: run.head_sha + ref: run.head_sha }); - // Check if all workflows are complete and successful - const isSuccess = allRuns.data.workflow_runs.every(run => - run.status === 'completed' && run.conclusion === 'success' - ); + // Count different check conclusions + const stats = checkRuns.data.check_runs.reduce((acc, check) => { + acc[check.conclusion] = (acc[check.conclusion] || 0) + 1; + return acc; + }, {}); - core.exportVariable('ALL_CHECKS_STATUS', isSuccess ? 'success' : 'failure'); + // Create status summary + const summary = Object.entries(stats) + .map(([status, count]) => `${count} ${status}`) + .join(', '); + + core.exportVariable('CHECKS_SUMMARY', summary); + + // Determine overall status + const hasFailures = stats.failure > 0; + const hasSuccess = stats.success > 0; + const hasCancelled = stats.cancelled > 0; + + let overallStatus; + if (hasFailures) { + overallStatus = 'failure'; + } else if (hasCancelled && !hasSuccess) { + overallStatus = 'cancelled'; + } else if (hasSuccess) { + overallStatus = 'success'; + } else { + overallStatus = 'unknown'; + } + + // Only set status if this is the last workflow to complete + const incompleteRuns = await github.rest.actions.listWorkflowRunsForRepo({ + owner, + repo, + head_sha: run.head_sha, + status: 'in_progress' + }); + + if (incompleteRuns.data.total_count === 0) { + core.exportVariable('ALL_CHECKS_STATUS', overallStatus); + core.exportVariable('SHOULD_NOTIFY', 'true'); + } else { + core.exportVariable('SHOULD_NOTIFY', 'false'); + } - name: Send Slack Notification for Success - if: env.ALL_CHECKS_STATUS == 'success' + if: env.SHOULD_NOTIFY == 'true' && env.ALL_CHECKS_STATUS == 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":white_check_mark: All PR checks passed!\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}", + "text": ":white_check_mark: All PR checks passed!\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}\nStatus Summary: ${{ env.CHECKS_SUMMARY }}", "username": "PR Checks Monitor", "icon_emoji": ":robot_face:" } - - name: Send Slack Notification for Failure - if: env.ALL_CHECKS_STATUS == 'failure' + - name: Send Slack Notification for Failure or Other Status + if: env.SHOULD_NOTIFY == 'true' && env.ALL_CHECKS_STATUS != 'success' uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: payload: | { - "text": ":x: Some PR checks failed!\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}", + "text": ":warning: PR Checks Status Update\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}\nStatus Summary: ${{ env.CHECKS_SUMMARY }}", "username": "PR Checks Monitor", "icon_emoji": ":robot_face:" } From 38be400b6504dc406e29573962a16d4f0e4d2e01 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 15:02:30 +0500 Subject: [PATCH 65/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 33 +++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 9efed065..9dfbffc2 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -9,6 +9,8 @@ on: jobs: notify-checks: runs-on: ubuntu-latest + # Only run for Dependabot + #if: github.actor == 'dependabot[bot]' steps: - name: Get PR Information id: get-pr-info @@ -86,6 +88,24 @@ jobs: if (incompleteRuns.data.total_count === 0) { core.exportVariable('ALL_CHECKS_STATUS', overallStatus); core.exportVariable('SHOULD_NOTIFY', 'true'); + + // If checks failed and PR exists, close it + if ((overallStatus === 'failure' || overallStatus === 'cancelled') && pr) { + await github.rest.pulls.update({ + owner, + repo, + pull_number: pr.number, + state: 'closed' + }); + + // Add comment explaining why PR was closed + await github.rest.issues.createComment({ + owner, + repo, + issue_number: pr.number, + body: `This PR was automatically closed because some checks failed.\nStatus Summary: ${summary}` + }); + } } else { core.exportVariable('SHOULD_NOTIFY', 'false'); } @@ -102,16 +122,3 @@ jobs: "username": "PR Checks Monitor", "icon_emoji": ":robot_face:" } - - - name: Send Slack Notification for Failure or Other Status - if: env.SHOULD_NOTIFY == 'true' && env.ALL_CHECKS_STATUS != 'success' - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - payload: | - { - "text": ":warning: PR Checks Status Update\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}\nStatus Summary: ${{ env.CHECKS_SUMMARY }}", - "username": "PR Checks Monitor", - "icon_emoji": ":robot_face:" - } From d700b5b38fd7c3b3f983400a96bb3fbe327d2c64 Mon Sep 17 00:00:00 2001 From: MuHamza30 Date: Tue, 27 May 2025 15:49:42 +0500 Subject: [PATCH 66/66] Update notify-dependabot.yml --- .github/workflows/notify-dependabot.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notify-dependabot.yml b/.github/workflows/notify-dependabot.yml index 9dfbffc2..60219096 100644 --- a/.github/workflows/notify-dependabot.yml +++ b/.github/workflows/notify-dependabot.yml @@ -1,4 +1,4 @@ -name: PR Checks Completed Notification +name: Dependabot Notifications on: workflow_run: @@ -9,8 +9,8 @@ on: jobs: notify-checks: runs-on: ubuntu-latest - # Only run for Dependabot - #if: github.actor == 'dependabot[bot]' + + if: github.actor == 'dependabot[bot]' steps: - name: Get PR Information id: get-pr-info @@ -118,7 +118,7 @@ jobs: with: payload: | { - "text": ":white_check_mark: All PR checks passed!\nRepository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}\nStatus Summary: ${{ env.CHECKS_SUMMARY }}", + "text": "Repository: ${{ github.repository }}\nTitle: ${{ env.PR_TITLE }}\nAuthor: ${{ env.PR_AUTHOR }}\nLink: ${{ env.PR_LINK }}\nStatus Summary: ${{ env.CHECKS_SUMMARY }}", "username": "PR Checks Monitor", "icon_emoji": ":robot_face:" }