Skip to content

GitHub Pages - Generate XML sitemap #48

GitHub Pages - Generate XML sitemap

GitHub Pages - Generate XML sitemap #48

Workflow file for this run

name: GitHub Pages - Generate XML sitemap
# Trigger the workflow manually or on a schedule (every day at midnight)
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
jobs:
sitemap_job:
runs-on: ubuntu-latest
name: Generate a sitemap
steps:
# Step to harden the runner for security purposes
- name: Harden Runner
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
disable-sudo: true
egress-policy: audit
allowed-endpoints: >
github.com:443
# Step to checkout the repository
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
# Step to generate the sitemap using the cicirello/generate-sitemap action
- name: Generate the sitemap
id: sitemap
uses: cicirello/generate-sitemap@eb8db82126ee30619883c8c43e8c49ec14ebd6dc # v1.10.1
with:
base-url-path: https://userstyles.github.typpi.online/
additional-extensions: doc docx ppt pptx js css json xml xlsx xls pdf md markdown txt lua yaml yml png
# Step to output the sitemap generation stats for debugging and verification
- name: Output stats
run: |
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}"
# Step to create a pull request with the new sitemap
- name: Create Pull Request with new SiteMap
id: create_pr
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
title: "Automated sitemap update"
body: >
Sitemap updated by the [generate-sitemap](https://github.com/cicirello/generate-sitemap)
GitHub action. Automated pull-request generated by the
[create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action.
# Step to set the pull request number or ID as an environment variable
- name: Set pull request number or ID
id: set_pr_number
run: |
pr_number=$(gh pr list --state open --base main --json number -q '.[0].number')
if [ -n "$pr_number" ]; then
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
else
echo "PR_NUMBER=" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}