-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (55 loc) · 1.88 KB
/
update-topics.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Update Topics Index (Weekly)
on:
schedule:
- cron: '0 0 * * 0' # Runs at 00:00 UTC every Sunday
workflow_dispatch: # Allows manual triggering
push:
branches:
- 'test/*' # Runs on any branch under test/
# Add explicit permissions for the GITHUB_TOKEN
permissions:
contents: write # Allows pushing to the repository
jobs:
update-topics:
runs-on: ubuntu-latest
# Add environment variables to control behavior
env:
IS_TEST: ${{ startsWith(github.ref, 'refs/heads/test/') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: pip install -r scripts/requirements.txt
- name: Build Index
run: python scripts/build_index.py
- name: Check for changes
id: changes
run: |
git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
- name: Configure Git
if: steps.changes.outputs.changes == 'true'
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
# Add debug information in test mode
- name: Debug Info (Test Mode)
if: env.IS_TEST == 'true'
run: |
echo "Changes detected: ${{ steps.changes.outputs.changes }}"
git diff --stat
git status
- name: Commit and push if there are changes
if: steps.changes.outputs.changes == 'true'
run: |
git add topics_index.json TOPICS.md
# Add [TEST] prefix to commit message on test branches
if [[ "${{ env.IS_TEST }}" == "true" ]]; then
git commit -m "[TEST] Auto-update topics index"
else
git commit -m "Auto-update topics index"
fi
git push