ci: fix wiki authentication and handle empty repositories
All checks were successful
Update Wiki Documentation / generate-docs (push) Successful in 2m14s

This commit is contained in:
Krzysztof Cieślik
2026-06-13 22:06:54 +02:00
parent 2d7ad8502c
commit 3f1a523908

View File

@@ -24,22 +24,29 @@ jobs:
./gradlew dokkaGfm ./gradlew dokkaGfm
- name: Sync to Wiki - name: Sync to Wiki
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
run: | run: |
git config --global user.name "Gitea Bot" git config --global user.name "Gitea Bot"
git config --global user.email "bot@gitea.io" git config --global user.email "bot@gitea.io"
WIKI_URL="https://${{ gitea.token }}@gitea.archvium.eu/KrzysztofC/Retro_HA.wiki.git" WIKI_URL="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@gitea.archvium.eu/KrzysztofC/Retro_HA.wiki.git"
git clone "$WIKI_URL" wiki_dir # Jeśli repozytorium jest puste, clone może zwrócić błąd, więc robimy fallback
git clone "$WIKI_URL" wiki_dir || (mkdir wiki_dir && cd wiki_dir && git init && git remote add origin "$WIKI_URL" && cd ..)
rm -rf wiki_dir/* # Usuwamy stare pliki (oprócz .git)
find wiki_dir -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# Kopiujemy nowe pliki
cp -r docs/wiki/gfm/* wiki_dir/ cp -r docs/wiki/gfm/* wiki_dir/
cd wiki_dir cd wiki_dir
git add . git add .
if ! git diff --cached --quiet; then if ! git diff --cached --quiet; then
git commit -m "Auto-update wiki from CI/CD" git commit -m "docs: auto-update wiki from CI/CD"
git push origin master git push -u origin master || git push -u origin main || git push -f origin master
else else
echo "No changes to sync." echo "No changes to sync."
fi fi