mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-01-17 14:18:17 +01:00
Add github action to close PRs with feedback and no action
This commit is contained in:
parent
8862239a11
commit
6c6f7021d1
50
.github/workflows/close-feedback-pr.yml
vendored
Normal file
50
.github/workflows/close-feedback-pr.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
name: Close PRs with Feedback
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
jobs:
|
||||||
|
close-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Close PR if it has label "feedback left" and no changes in 7 days
|
||||||
|
uses: actions/github-script@v3
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const { data: pullRequests } = await github.pulls.list({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'open',
|
||||||
|
base: 'master',
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const pullRequest of pullRequests) {
|
||||||
|
const { data: labels } = await github.issues.listLabelsOnIssue({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pullRequest.number,
|
||||||
|
});
|
||||||
|
|
||||||
|
const feedbackLabel = labels.find((label) => label.name === 'feedback left');
|
||||||
|
if (feedbackLabel) {
|
||||||
|
const lastUpdated = new Date(pullRequest.updated_at);
|
||||||
|
const sevenDaysAgo = new Date();
|
||||||
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
||||||
|
|
||||||
|
if (lastUpdated < sevenDaysAgo) {
|
||||||
|
await github.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pullRequest.number,
|
||||||
|
body: 'Closing this PR because there has been no activity for the past 7 days. Feel free to reopen if you have any feedback.',
|
||||||
|
});
|
||||||
|
await github.pulls.update({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
pull_number: pullRequest.number,
|
||||||
|
state: 'closed',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user