Skip to content

Generate Sitemap

Generate Sitemap #21

name: Generate Sitemap
on:
# Schedule weekly run (Sunday at midnight)
schedule:
- cron: "0 0 * * 0"
# Allow manual trigger
workflow_dispatch:
# Run on push to main branch
push:
branches:
- main
paths:
- "src/helpers/formOptions.js"
jobs:
generate-sitemap:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
cache-dependency-path: "app/package-lock.json"
- name: Install dependencies
run: npm ci
working-directory: app
- name: Generate sitemap
run: npm run generate:sitemap
working-directory: app
- name: Commit and push sitemap
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git add app/public/sitemap.xml
git diff --quiet && git diff --staged --quiet || git commit -m "Update sitemap.xml"
git push