Repository navigation
179 lines (160 loc) · 6.17 KB
/
Copy pathupdate.yml
File metadata and controls
179 lines (160 loc) · 6.17 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Update papers
on:
schedule:
- cron: "17 6 * * *"
- cron: "17 18 * * *"
workflow_dispatch:
inputs:
max_results:
description: Number of recent arXiv matches to inspect
required: false
default: "500"
permissions: {}
concurrency:
group: update-papers
cancel-in-progress: false
jobs:
# arXiv's edge intermittently 406s shared CI egress IPs, so each matrix leg
# runs on a fresh runner VM and draws a fresh egress address. Legs run one at
# a time and stop after the first success, recorded via the collect-ok
# marker artifact that the deploy job requires.
collect:
runs-on: ubuntu-latest
timeout-minutes: 25
continue-on-error: true
strategy:
fail-fast: false
max-parallel: 1
matrix:
attempt: [1, 2, 3]
permissions:
actions: read
contents: write
pages: write
steps:
- name: Check for a prior successful attempt
id: prior
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh run download "$GITHUB_RUN_ID" --repo "$GITHUB_REPOSITORY" \
--name collect-ok --dir .prior-success >/dev/null 2>&1; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Check out repository
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up Python
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Test collector
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
run: python3 -m unittest discover -s tests -v
- name: Collect and render papers
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
env:
MAX_RESULTS: ${{ inputs.max_results || '500' }}
run: |
# arXiv's edge blocks shared CI egress pools in ~10-30 minute
# windows; stagger legs to draw fresh VMs across a wider span.
sleep $(( (${{ matrix.attempt }} - 1) * 480 ))
python3 scripts/collect.py --max-results "$MAX_RESULTS"
- name: Validate generated data
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
run: |
python3 -m unittest discover -s tests -v
node --check docs/app.mjs
node --test tests/site.test.mjs
python3 scripts/collect.py --render-only
git diff --check
- name: Commit changes
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
id: commit
run: |
if git diff --quiet; then
echo "No paper changes found"
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add README.md papers.md data/papers.json data/papers.csv docs/data
git commit -m "chore(data): update arXiv papers"
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Push changes
id: push
if: ${{ !failure() && steps.commit.outputs.changed == 'true' }}
continue-on-error: true
run: git push origin HEAD:main
- name: Retry after a concurrent main update
if: steps.push.outcome == 'failure'
env:
MAX_RESULTS: ${{ inputs.max_results || '500' }}
run: |
git fetch origin main
git switch --detach origin/main
python3 -m unittest discover -s tests -v
node --check docs/app.mjs
node --test tests/site.test.mjs
python3 scripts/collect.py --max-results "$MAX_RESULTS"
python3 -m unittest discover -s tests -v
python3 scripts/collect.py --render-only
git diff --check
if git diff --quiet; then
echo "Concurrent update already contains current data"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add README.md papers.md data/papers.json data/papers.csv docs/data
git commit -m "chore(data): update arXiv papers"
git push origin HEAD:main
- name: Configure Pages
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6
- name: Upload Pages artifact
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
with:
path: docs
- name: Record successful collection
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
run: mkdir -p marker && echo "attempt ${{ matrix.attempt }}" > marker/ok
- name: Mark collection as done
if: ${{ !failure() && steps.prior.outputs.found == 'false' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: collect-ok
path: marker
deploy:
needs: collect
if: always()
runs-on: ubuntu-latest
permissions:
actions: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Check for a successful collection
id: marker
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: collect-ok
- name: Report skipped collection
if: steps.marker.outcome == 'failure'
run: |
echo "::warning:: arXiv blocked all collection attempts; skipping today's update"
- name: Deploy GitHub Pages
if: steps.marker.outcome == 'success'
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5