Skip to content

Label Previously Merged PRs #11

Label Previously Merged PRs

Label Previously Merged PRs #11

Workflow file for this run

name: Label Previously Merged PRs
on:
workflow_dispatch: # Manual trigger
jobs:
label_merged_prs:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/github-script@v7
with:
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
sort: 'updated',
direction: 'desc',
per_page: 100
});
for (const pr of prs) {
if (pr.merged_at) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['hacktoberfest-accepted']
});
console.log(`Added label to PR #${pr.number}`);
}
}