Update whitelists #112
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 whitelists | |
on: | |
schedule: | |
- cron: '0 */3 * * *' # At minute 0 past every 3rd hour. | |
workflow_dispatch: | |
jobs: | |
update-whitelists: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
ref: main | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci --omit=dev | |
- name: Process the Googlebot whitelist | |
run: node scripts/googlebot.js | |
- name: Process the Bingbot whitelist | |
run: node scripts/bingbot.js | |
- name: Process the Cloudflare whitelist | |
run: node scripts/cloudflare.js | |
- name: Add files to staging | |
run: git add . | |
- name: Commit and push changes | |
run: | | |
git config user.name "Sefinek Actions" | |
git config user.email "[email protected]" | |
if [ -n "$(git status -s)" ]; then | |
MODIFIED_FILES=$(git diff --name-only HEAD) | |
FILE_COUNT=$(echo "$MODIFIED_FILES" | wc -l) | |
if [ "$FILE_COUNT" -gt 0 ]; then | |
git commit -am "Automatic whitelist update [$FILE_COUNT files]" -m "$MODIFIED_FILES" | |
git push origin main | |
else | |
echo "Canceled. No changes were made." | |
fi | |
else | |
echo "Canceled. No changes to commit." | |
fi |