diff --git a/.github/workflows/generate-sitemap.yml b/.github/workflows/generate-sitemap.yml new file mode 100644 index 0000000..bf71c5a --- /dev/null +++ b/.github/workflows/generate-sitemap.yml @@ -0,0 +1,42 @@ +name: Generate Sitemap +permissions: + contents: write + + +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + + - name: Install dependencies + run: npm install + + - name: Install next-sitemap + run: npm install next-sitemap + + - name: Generate Sitemap + run: npx next-sitemap + + - name: Commit sitemap + run: | + git config --local user.name 'github-actions' + git config --local user.email 'github-actions@github.com' + git add ./app/sitemap.xml + git commit -m 'chore: update sitemap' || echo 'No changes to commit' + git push origin ${{ github.head_ref }}