Merge pull request 'Add sitemap CI/CD' (#7) from ari/purplebored.pl:main into main

Reviewed-on: https://git.ari.lt/purplebored/purplebored.pl/pulls/7
This commit was merged in pull request #7.
This commit is contained in:
~purplebored
2025-10-14 16:47:59 +00:00
2 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
on:
push:
paths:
- "pages/**"
- "blog/**"
- "sitemap.sh"
- "index.xhtml"
jobs:
stats:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_TOKEN }}
- name: Set up repository
run: |
git reset --hard
git pull
git reset --hard
- name: Generate sitemap
run: |
sh ./sitemap.sh
- name: Stage the changes
run: |
git add sitemap.xml
- name: Commit and Push Changes
run: |
if git diff --staged --quiet; then
echo "No changes to commit."
else
git config --local user.email "sitemap@localhost"
git config --local user.name "Sitemap CI/CD"
git commit -am "[skip ci] Update sitemap" || echo "No changes to commit"
git push origin HEAD -f
fi

14
sitemap.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -eu
main() {
echo '<urlset>'
echo '<url><loc>https://purplebored.pl/</loc><priority>1.0</priority></url>'
find pages/ blog/ -name '*.xhtml' -not -name 'template.xhtml' | while read -r file; do
echo "<url><loc>https://purplebored.pl/${file}</loc><priority>1.0</priority></url>"
done
echo '</urlset>'
}
main >sitemap.xml