From e66c3077008ee827a56f36c56b54a7a15a036d93 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 15 Jun 2026 05:35:59 +0000 Subject: [PATCH] chore: restore alert-bridge.yml after upstream sync (fork patch) --- .github/workflows/alert-bridge.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/alert-bridge.yml diff --git a/.github/workflows/alert-bridge.yml b/.github/workflows/alert-bridge.yml new file mode 100644 index 000000000000..3a62df801206 --- /dev/null +++ b/.github/workflows/alert-bridge.yml @@ -0,0 +1,52 @@ +name: Alert Bridge +on: + workflow_dispatch: + inputs: + mode: + required: true + type: choice + options: [list, dismiss] + description: 'list = download open alerts; dismiss = patch alerts to dismissed' + dismissals: + required: false + default: '[]' + description: 'JSON array of {number,reason,comment} — only used in dismiss mode' + +permissions: + security-events: write + contents: read + +jobs: + bridge: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: + - name: LIST + if: ${{ inputs.mode == 'list' }} + run: | + gh api --paginate "repos/${{ github.repository }}/code-scanning/alerts?state=open&per_page=100" > alerts.json + echo "## Open code-scanning alerts" >> $GITHUB_STEP_SUMMARY + echo "$(jq length alerts.json) open alert(s)" >> $GITHUB_STEP_SUMMARY + + - name: Upload alerts artifact + if: ${{ inputs.mode == 'list' }} + uses: actions/upload-artifact@v4 + with: + name: alerts + path: alerts.json + + - name: DISMISS + if: ${{ inputs.mode == 'dismiss' }} + run: | + echo '${{ inputs.dismissals }}' | jq -c '.[]' | while read d; do + n=$(jq -r .number <<<"$d") + r=$(jq -r .reason <<<"$d") + c=$(jq -r .comment <<<"$d") + gh api -X PATCH "repos/${{ github.repository }}/code-scanning/alerts/$n" \ + -f state=dismissed \ + -f dismissed_reason="$r" \ + -f dismissed_comment="$c" \ + && echo "dismissed #$n ($r)" >> $GITHUB_STEP_SUMMARY \ + || echo "FAILED #$n" >> $GITHUB_STEP_SUMMARY + done