-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (62 loc) · 2.28 KB
/
puzzle.yml
File metadata and controls
76 lines (62 loc) · 2.28 KB
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
68
69
70
71
72
73
74
75
76
name: Generate Daily Puzzle
on:
schedule:
- cron: '0 12 * * *' # runs at 12:00 PM UTC daily
workflow_dispatch:
inputs:
force_overwrite:
description: 'Force overwrite existing puzzle'
required: true
type: boolean
default: true
permissions:
contents: write
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout Main
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch main and gh-pages branches
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install commander
run: npm install commander --no-save
- name: Run Generator Script
run: |
# If triggered manually AND the box is checked, add --force
if [ "${{ github.event.inputs.force_overwrite }}" == "true" ]; then
node bin/generate_daily.js --verbose --offset 1 --force
else
# For the daily cron job, just run it normally
node bin/generate_daily.js --verbose --offset 1
fi
- name: Update metadata
run: node bin/generate_meta.js
- name: Configure Git
run: |
git config --global user.name "🤖 Rangler"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: 1. Commit to Main (Source Archive)
run: |
git add public/daily/*.json
# The || echo prevents the action from failing if there are no changes
git commit -m "🤖 add latest puzzle to main archive [skip ci]" || echo "No changes"
git push origin main
- name: 2. Commit to gh-pages (Live Deployment)
run: |
git checkout -B gh-pages origin/gh-pages
# Pull the fresh JSON files out of the main branch
git checkout main -- public/daily/
# Move them from /public/daily to /daily (where the live site expects them)
mkdir -p daily
cp public/daily/*.json daily/
# Clean up the public folder artifact we just used
rm -rf public
# Ship it!
git add daily/*.json
git commit -m "update daily puzzle" || echo "No changes"
git push origin gh-pages