diff --git a/.forgejo/workflows/sitemap.yml b/.forgejo/workflows/sitemap.yml new file mode 100644 index 0000000..8514d18 --- /dev/null +++ b/.forgejo/workflows/sitemap.yml @@ -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 diff --git a/sitemap.sh b/sitemap.sh new file mode 100755 index 0000000..1ac9a95 --- /dev/null +++ b/sitemap.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -eu + +main() { + echo '' + echo 'https://purplebored.pl/1.0' + find pages/ blog/ -name '*.xhtml' -not -name 'template.xhtml' | while read -r file; do + echo "https://purplebored.pl/${file}1.0" + done + echo '' +} + +main >sitemap.xml