Files
build/.github/workflows/pr-label-on-approved.yml
dependabot[bot] c3a7854f73 build(deps): bump actions/download-artifact from 4 to 5
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-14 13:49:34 +02:00

55 lines
1.9 KiB
YAML

name: PR review labeler
on:
workflow_run:
workflows: ["PR review listener"]
types: [completed]
jobs:
label:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Download PR number artifact from upstream run
uses: actions/download-artifact@v5
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}`);
}
}