-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 2.09 KB
/
update_used_words.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
name: Update Word List
on:
schedule:
# The latest time when there's still an inhabited place (UTC-10) that hasn't rolled over to the next day is at 09:59 UTC.
# The latest time when there's still an uninhabited place (UTC-12) that hasn't rolled over to the next day is at 11:59 UTC.
# Observed update of source is between 4:00 AM and 4:20 AM PDT, 11:00 and 11:20 UTC.
# Schedule to run starting at 10:07 UTC, 3:07 AM PDT, polling every 20 minutes until
# update received, or stop trying after 18 attempts (6 hours).
- cron: '7 10 * * *'
workflow_dispatch: # Allows manual triggering
jobs:
update-gist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
working-directory: ./scripts
- name: Run scraper and update Gist
env:
USED_WORDS_SOURCE_URL: ${{ secrets.USED_WORDS_SOURCE_URL }}
GIST_UPDATE_TOKEN: ${{ secrets.GIST_UPDATE_TOKEN }}
GIST_ID: ${{ secrets.GIST_ID }}
working-directory: ./scripts
run: |
set +e # Allow script to continue on non-zero exit codes
TIMESTAMP_FORMAT='%Y-%m-%d %H:%M:%S'
echo "$(date +"$TIMESTAMP_FORMAT") - Starting run script"
for i in {1..36} # Loop max 36 times (6 hours)
do
echo "$(date +"$TIMESTAMP_FORMAT") - Invoking update-used-words.js"
node ./update-used-words.js
if [ $? -eq 0 ]; then
echo "$(date +"$TIMESTAMP_FORMAT") - List updated, exiting workflow."
exit 0
fi
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "$(date +"$TIMESTAMP_FORMAT") - Manual trigger detected, exiting."
exit 2
fi
echo "$(date +"$TIMESTAMP_FORMAT") - Resource not updated, sleeping for 10 minutes"
sleep $((60 * 10)) # Sleep for 10 minutes
done
echo "$(date +"$TIMESTAMP_FORMAT") - Resource update not detected within time limit."
exit 1