-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1006 from microsoft/arkalyanms-stale-gha
Create stale.yml github action to poke label owners for responses
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Comment on stale issues | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # This will run daily at midnight | ||
|
||
jobs: | ||
comment-stale-issues: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Comment on stale issues | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
LABEL_OWNER_MAPPING: | | ||
area-debugging: @wardengnaw | ||
area-extensionmanagement: @aarnott | ||
area-identity: @AndreyTretyak | ||
area-nuget: @kartheekp-ms | ||
area-project: @tmeschter | ||
area-project-cps: @michael-eng | ||
area-razor: @phil-allen-msft | ||
area-restore: @kartheekp-ms | ||
area-sdk: @nagilson | ||
area-telemetry: @jonathanjyi | ||
area-templates: @smitpatel | ||
area-maui: @AllenD-MSFT | ||
area-unity: @jbevain | ||
area-roslyn: @arkalyanms | ||
run: | | ||
LABEL_OWNER_MAPPING=$(echo "$LABEL_OWNER_MAPPING" | jq -R 'split("\n")[:-1] | map(split(": ")) | map({(.[0]): .[1]}) | add') | ||
STALE_DATE=$(date -d '14 days ago' +%Y-%m-%d) | ||
ISSUES=$(gh issue list --state open --search "updated:<$STALE_DATE" --json number,labels,assignees --jq '.[] | select(.labels | length > 0)') | ||
for issue in $(echo "${ISSUES}" | jq -r '.number'); do | ||
ASSIGNEES=$(echo "${ISSUES}" | jq -r ". | select(.number == ${issue}) | .assignees[].login" | head -n 1) | ||
if [ ! -z "$ASSIGNEES" ]; then | ||
COMMENT="This issue has been marked as stale for 14 days. @$ASSIGNEES, could you please take a look?" | ||
gh issue comment $issue --body "$COMMENT" | ||
else | ||
LABELS=$(echo "${ISSUES}" | jq -r ". | select(.number == ${issue}) | .labels[].name") | ||
for label in $LABELS; do | ||
OWNERS=$(echo $LABEL_OWNER_MAPPING | jq -r ".[\"$label\"]") | ||
if [ ! -z "$OWNERS" ]; then | ||
COMMENT="This issue has been marked as stale for 14 days. $OWNERS, could you please take a look?" | ||
gh issue comment $issue --body "$COMMENT" | ||
break # This stops the loop after the first matched label and its owners are found and tagged | ||
fi | ||
done | ||
fi | ||
done |