Generate Sitemap #22
This file contains hidden or 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: 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 |