add stale discussion check #24
Workflow file for this run
This file contains hidden or 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
| name: Stale GitHub Discussions | |
| on: | |
| pull_request: # just for debug purposes | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 6 * * 1" # Every Monday at 6:00 AM UTC (8:00 AM CET) | |
| jobs: | |
| run: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.repository_owner == 'XRPLF' }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| - name: Fetch old discussions | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Calculate date one year ago (365 days) | |
| ONE_YEAR_AGO=$(date -u -d "@$(($(date +%s) - 31536000))" '+%Y-%m-%dT%H:%M:%SZ') | |
| echo "Fetching discussions not updated in over a year (before: $ONE_YEAR_AGO)" | |
| # Fetch discussions using GitHub GraphQL API | |
| gh api graphql -f query=' | |
| query($owner: String!, $repo: String!, $cursor: String) { | |
| repository(owner: $owner, name: $repo) { | |
| discussions(first: 100, after: $cursor, orderBy: {field: UPDATED_AT, direction: ASC}) { | |
| pageInfo { | |
| hasNextPage | |
| endCursor | |
| } | |
| nodes { | |
| number | |
| title | |
| url | |
| createdAt | |
| updatedAt | |
| closed | |
| locked | |
| } | |
| } | |
| } | |
| } | |
| ' -f owner="${{ github.repository_owner }}" -f repo="${{ github.event.repository.name }}" > discussions.json | |
| # Parse and filter discussions not updated in over 1 year (exclude closed) | |
| echo "=== Open discussions not updated in over 1 year ===" | |
| jq -r --arg cutoff "$ONE_YEAR_AGO" ' | |
| .data.repository.discussions.nodes[] | | |
| select(.updatedAt < $cutoff and .closed == false) | | |
| "Number: \(.number)\nTitle: \(.title)\nURL: \(.url)\nCreated: \(.createdAt)\nUpdated: \(.updatedAt)\nLocked: \(.locked)\n---" | |
| ' discussions.json |