Skip to content

Commit a0dcde5

Browse files
committed
augment attempt
1 parent 8b46fbe commit a0dcde5

File tree

2 files changed

+37
-194
lines changed

2 files changed

+37
-194
lines changed

.github/comment-close-old-discussions.py

Lines changed: 0 additions & 178 deletions
This file was deleted.

.github/workflows/discussions.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,43 @@ jobs:
1313

1414
steps:
1515
- name: Check out code
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v5
1717

18-
- name: Set up python
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: "3.12"
22-
23-
- name: Install pip packages
18+
- name: Fetch old discussions
19+
env:
20+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2421
run: |
25-
pip install python-graphql-client
26-
pip install python-dateutil
27-
working-directory: ${{ github.workspace }}
22+
# Calculate date one year ago (365 days)
23+
ONE_YEAR_AGO=$(date -u -d "@$(($(date +%s) - 31536000))" '+%Y-%m-%dT%H:%M:%SZ')
24+
echo "Fetching discussions older than: $ONE_YEAR_AGO"
2825
29-
- name: Run script comment-close-old-discussions.py
30-
run: |
31-
python .github/comment-close-old-discussions.py
32-
working-directory: ${{ github.workspace }}
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
# Fetch discussions using GitHub GraphQL API
27+
gh api graphql -f query='
28+
query($owner: String!, $repo: String!, $cursor: String) {
29+
repository(owner: $owner, name: $repo) {
30+
discussions(first: 100, after: $cursor, orderBy: {field: UPDATED_AT, direction: ASC}) {
31+
pageInfo {
32+
hasNextPage
33+
endCursor
34+
}
35+
nodes {
36+
number
37+
title
38+
url
39+
createdAt
40+
updatedAt
41+
closed
42+
locked
43+
}
44+
}
45+
}
46+
}
47+
' -f owner="${{ github.repository_owner }}" -f repo="${{ github.event.repository.name }}" > discussions.json
48+
49+
# Parse and filter discussions older than 1 year
50+
echo "=== Discussions older than 1 year ==="
51+
jq -r --arg cutoff "$ONE_YEAR_AGO" '
52+
.data.repository.discussions.nodes[] |
53+
select(.updatedAt < $cutoff) |
54+
"Number: \(.number)\nTitle: \(.title)\nURL: \(.url)\nCreated: \(.createdAt)\nUpdated: \(.updatedAt)\nClosed: \(.closed)\nLocked: \(.locked)\n---"
55+
' discussions.json

0 commit comments

Comments
 (0)