* [StepSecurity] ci: Harden GitHub Actions Signed-off-by: StepSecurity Bot <bot@stepsecurity.io> * imprement coderabbit recommendations --------- Signed-off-by: StepSecurity Bot <bot@stepsecurity.io> Co-authored-by: Igor Velkov <325961+iav@users.noreply.github.com>
58 lines
2.0 KiB
YAML
58 lines
2.0 KiB
YAML
name: "Maintenance: Label PR on approval"
|
|
on:
|
|
workflow_run:
|
|
workflows: ["Maintenance: Listen PR review"]
|
|
types: [completed]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
label:
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Download PR number artifact from upstream run
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: pr-number-${{ github.event.workflow_run.id }} # same unique name
|
|
path: .
|
|
run-id: ${{ github.event.workflow_run.id }} # ← CRITICAL: fetch from the upstream run
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- id: pr
|
|
run: echo "number=$(cat pr.txt)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Label when approved
|
|
uses: j-fulbright/label-when-approved-action@v1.2
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
label: 'Ready to merge'
|
|
require_committers_approval: 'true'
|
|
remove_label_when_approval_missing: 'true'
|
|
comment: '✅ This PR has been reviewed and approved — all set for merge!'
|
|
pullRequestNumber: ${{ steps.pr.outputs.number }}
|
|
|
|
- name: Remove review-related labels
|
|
if: ${{ success() }}
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const { owner, repo } = context.repo;
|
|
const issue_number = ${{ steps.pr.outputs.number }};
|
|
const labelsToRemove = ["Needs review", "Work in progress", "Backlog", "Can be closed?", "Help needed", "Needs Documentation"];
|
|
|
|
for (const name of labelsToRemove) {
|
|
try {
|
|
await github.rest.issues.removeLabel({ owner, repo, issue_number, name });
|
|
core.info(`Removed label "${name}"`);
|
|
} catch (e) {
|
|
core.warning(`Could not remove label "${name}": ${e.message}`);
|
|
}
|
|
} |