Skip to content

Label Old Issues

Label Old Issues #13

Workflow file for this run

name: Label Old Issues
on:
schedule:
- cron: "0 0 * * *"
jobs:
label-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Label Old Issues
run: |
open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues?state=open" \
| jq -r '.[] | .number')
for issue in $open_issues; do
# Get the last updated timestamp of the issue
last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
| jq -r '.updated_at')
days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
if [ $days_since_update -gt 5 ]; then
# Add the "up for grabs" label to the issue
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"labels":["up for grabs"]}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue/labels"
# Optionally, add a comment explaining the label
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"body":"This issue has been marked as **up for grabs** because it has been inactive for more than 5 days. Feel free to take it on!"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments"
fi
done