Update Word List #116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |