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:
41
.forgejo/workflows/sitemap.yml
Normal file
41
.forgejo/workflows/sitemap.yml
Normal 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
14
sitemap.sh
Executable 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
|
||||||
Reference in New Issue
Block a user