Skip to content

Commit

Permalink
Merge pull request #1006 from microsoft/arkalyanms-stale-gha
Browse files Browse the repository at this point in the history
Create stale.yml github action to poke label owners for responses
  • Loading branch information
arunchndr authored Mar 20, 2024
2 parents d22de37 + e044032 commit d7c49ac
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/stale.yml
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

0 comments on commit d7c49ac

Please sign in to comment.