Skip to content

Update Traffic Views #557

Update Traffic Views

Update Traffic Views #557

name: Update Traffic Views
on:
schedule:
- cron: '0 */4 * * *'
jobs:
update-traffic-views:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Pull latest changes
run: git pull origin main
- name: Install dependencies
run: npm install
- name: Run update-traffic-views script
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_GITHUB_TOKEN }}
GITHUB_USER: toFrankie
GITHUB_REPO: blog
run: node scripts/update-traffic-views.js
- name: Check if traffic-views.svg has changed
id: check_changes
run: |
if git diff --exit-code docs/traffic-views.svg; then
echo "file_changed=false" >> $GITHUB_ENV
else
echo "file_changed=true" >> $GITHUB_ENV
fi
- name: Commit changes
if: env.file_changed == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add docs/traffic-views.svg
git commit -m "docs: update traffic views"
git push origin main