Skip to content

Housekeeping - Close stale qa issues with label "staging" #27

Housekeeping - Close stale qa issues with label "staging"

Housekeeping - Close stale qa issues with label "staging" #27

name: Housekeeping - Close stale qa issues with label "staging"
on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch:
permissions:
issues: write
contents: read
actions: write
jobs:
close-stale-issues:
runs-on: ubuntu-latest
environment: STAGE
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Close all issues with the PAT_TOKEN
run: |
echo "Closing all issues with the PAT_TOKEN"
gh issue list --label "staging" --state open --json number,labels | jq -c '.[]' | while read -r issue; do
issue_number=$(echo "$issue" | jq -r '.number')
echo "Closing issue #$issue_number"
curl -X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
-d "{\"state\": \"closed\"}" \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue_number"
done
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}