Update Word List #66
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 | |
echo "Entered workflow run: block" | |
for i in {1..18} # Loop max 18 times (6 hours) | |
do | |
node ./update-used-words.js | |
if [ $? -eq 0 ]; then | |
echo "Resource updated, exiting." | |
exit 0 | |
fi | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
echo "Manual trigger detected, exiting." | |
exit 2 | |
fi | |
echo "Resource not updated, sleeping for 1 minute" | |
sleep $((60 * 20)) # Sleep for 20 minutes | |
done | |
echo "Resource update not detected within time limit." | |
exit 1 | |