66 workflow_dispatch :
77
88permissions :
9- contents : read
9+ contents : write
1010 pages : write
1111 id-token : write
1212
2727 steps :
2828 - name : Checkout
2929 uses : actions/checkout@v4
30+ with :
31+ token : ${{ secrets.GITHUB_TOKEN }}
3032
3133 - name : Detect package manager
3234 id : detect-package-manager
@@ -73,32 +75,14 @@ jobs:
7375 restore-keys : |
7476 ${{ runner.os }}-astro-cache-
7577
76- # ===== /content cache keyed by content/meta.json (source commit) =====
77- - name : Restore content cache
78- id : content-cache
79- uses : actions/cache/restore@v4
80- with :
81- path : ${{ env.BUILD_PATH }}/content
82- key : ${{ runner.os }}-content-${{ hashFiles('content/meta.json') }}-primary
83- restore-keys : |
84- ${{ runner.os }}-content-${{ hashFiles('content/meta.json') }}-
85- ${{ runner.os }}-content-
86-
87- # Always run; import should reuse restored files and fetch only updates
78+ # Fetch the latest data
8879 - name : Fetch data
8980 run : npm run import
9081 working-directory : ${{ env.BUILD_PATH }}
9182 env :
9283 STADIA_MAPS_API_KEY : ${{ secrets.STADIA_MAPS_API_KEY }}
9384 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9485
95- # Save refreshed /content with a unique key to avoid collisions
96- - name : Save content cache
97- uses : actions/cache/save@v4
98- with :
99- path : ${{ env.BUILD_PATH }}/content
100- key : ${{ runner.os }}-content-${{ hashFiles('content/meta.json') }}-${{ github.run_id }}
101-
10286 - name : Print env
10387 run : |
10488 echo "vars.SITE_URL='${{ vars.SITE_URL }}'"
@@ -112,6 +96,42 @@ jobs:
11296 SITE_URL : ${{ vars.SITE_URL }}
11397 BASE_PATH : ${{ vars.BASE_PATH }}
11498
99+ - name : Run tests
100+ run : |
101+ # TODO: Implement actual tests
102+ echo "Tests placeholder - returning success"
103+ exit 0
104+ working-directory : ${{ env.BUILD_PATH }}
105+
106+ - name : Commit content updates
107+ if : success()
108+ run : |
109+ # Configure git
110+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
111+ git config --local user.name "github-actions[bot]"
112+
113+ # Check if there are changes to commit
114+ if [ -n "$(git status --porcelain content/)" ]; then
115+ # Read upstream commit from meta.json
116+ UPSTREAM_COMMIT=$(jq -r '.commitHash' content/meta.json)
117+ echo "Upstream commit from meta.json: $UPSTREAM_COMMIT"
118+
119+ # Stage content changes, including content/meta.json
120+ git add content/
121+
122+ # Create commit message with upstream reference
123+ git commit -m "Auto import content $UPSTREAM_COMMIT
124+
125+ https://github.com/owddm/public/commit/$UPSTREAM_COMMIT"
126+
127+ # Push changes
128+ git push
129+
130+ echo "Content updates committed and pushed"
131+ else
132+ echo "No content changes to commit"
133+ fi
134+
115135 # IMPORTANT: Always save Astro cache so new variants produced this run are kept.
116136 # Append run_id to avoid "already exists", and rely on the restore prefix above to pick the newest next time.
117137 - name : Save Astro cache (always)
0 commit comments