Skip to content

Commit

Permalink
Updating the workflow to skip draft PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
anupama2501 authored and git-ival committed Oct 9, 2024
1 parent 6eaa9b4 commit ace3394
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/stale-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Check PRs and compile report
id: compile_report
uses: actions/github-script@211cb3fefb35a799baa5156f9321bb774fe56294
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
const fiveDaysAgo = new Date(new Date().setDate(new Date().getDate() - 5));
Expand Down Expand Up @@ -51,8 +51,11 @@ jobs:
per_page: 100,
});
if (pr.draft) {
continue;
}
if ( reviews.data.length == 0 && createdDate < fiveDaysAgo ) {
noReviewsReport += `${pr.title} #${pr.number} ${pr.html_url} ${pr.user.login}\n`;
noReviewsReport += `${pr.title} | #${pr.number} ${pr.html_url} by ${pr.user.login}\n`;
}
else {
for (const review of reviews.data) {
Expand All @@ -68,37 +71,37 @@ jobs:
}
}
} catch( error ){
hasErrors += `${pr.title} (#${pr.number}) ${pr.html_url} - Error: ${error} \n`;
hasErrors += `${pr.title} | (#${pr.number}) ${pr.html_url} - Error: ${error} \n`;
}
if ( lastReviewDate && (lastReviewDate < threeDaysAgo && updatedDate <= lastReviewDate) && statesCompare.includes(lastReviewStateOne) && statesCompare.includes(lastReviewStateTwo) ) {
needsChanges += `${pr.title} (#${pr.number}) ${pr.html_url} ${pr.user.login} \n`;
needsChanges += `${pr.title} | (#${pr.number}) ${pr.html_url} by ${pr.user.login} \n`;
} else if ( lastReviewDate && (updatedDate > lastReviewDate) && (updatedDate < threeDaysAgo) ){
needsReviews += `${pr.title} (#${pr.number}) ${pr.html_url} ${pr.user.login} \n`;
needsReviews += `${pr.title} | (#${pr.number}) ${pr.html_url} by ${pr.user.login} \n`;
} else if ( lastReviewDate && numberOfApprovedState >=2 && (lastReviewDate < threeDaysAgo) && !statesCompare.includes(lastReviewStateOne) ) {
needsMerge += `${pr.title} (#${pr.number}) ${pr.html_url} ${pr.user.login} \n`;
needsMerge += `${pr.title} | (#${pr.number}) ${pr.html_url} by ${pr.user.login} \n`;
}
}
if ( noReviewsReport ) {
report += `PRs with no reviews yet: \n` + noReviewsReport +`\n\n`
report += `*PRs with no reviews yet:* \n` + noReviewsReport +`\n\n`
}
if ( needsReviews ) {
report += `PRs that need reviews: \n`+ needsReviews +`\n\n`
report += `*PRs that need reviews:* \n`+ needsReviews +`\n\n`
}
if ( needsChanges ) {
report += `PRs with changes requested: \n`+ needsChanges +`\n\n`
report += `*PRs with changes requested:* \n`+ needsChanges +`\n\n`
}
if ( needsMerge ) {
report += `PRs that need to be merged: \n` + needsMerge
report += `*PRs that need to be merged:* \n` + needsMerge
}
if ( hasErrors ) {
report += `PRs that have errors when fetching: \n` + hasErrors
report += `*PRs that have errors when fetching:* \n` + hasErrors
}
return report;
} catch( error ){
report += `There is an error getting PR Status report - Error: ${error} \n`;
report += `*There is an error getting PR Status report - Error:* ${error} \n`;
return report;
}
Expand All @@ -108,8 +111,8 @@ jobs:
run: |
result="${{ steps.compile_report.outputs.result }}"
if [[ -n "$result" ]]; then
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"PR Status Report:\n$result\"}" ${{ secrets.SLACK_WEBHOOK_URL }}
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"*PR Status Report:*\n\n$result\"}" ${{ secrets.SLACK_WEBHOOK_URL }}
else
curl -X POST -H 'Content-type: application/json' --data '{"text":"PR Status Report: There are errors please check the GH actions logs"}' ${{ secrets.SLACK_WEBHOOK_URL }}
curl -X POST -H 'Content-type: application/json' --data '{"text":"*PR Status Report:* There are errors please check the GH actions logs \n\n"}' ${{ secrets.SLACK_WEBHOOK_URL }}
fi
shell: bash
shell: bash

0 comments on commit ace3394

Please sign in to comment.