diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..725c349 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,63 @@ +name: Publish site + +on: + push: + branches: [main] + workflow_dispatch: + +env: + QUARTO_VERSION: "1.10.18" + +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Quarto + run: | + set -e + curl -sSL -o /tmp/quarto.tar.gz \ + "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.tar.gz" + mkdir -p "$HOME/opt" + tar -xzf /tmp/quarto.tar.gz -C "$HOME/opt" + echo "$HOME/opt/quarto-${QUARTO_VERSION}/bin" >> "$GITHUB_PATH" + + - name: Render + run: quarto render + + - name: Deploy to gh-pages + env: + TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + set -e + REMOTE="https://x-access-token:${TOKEN}@gitea.spacilovi.eu/${GITHUB_REPOSITORY}.git" + + git config --global user.name "gitea-actions" + git config --global user.email "gitea-actions@spacilovi.eu" + + # pracovní kopie gh-pages (zachová dosavadní historii větve) + if git ls-remote --exit-code "$REMOTE" gh-pages >/dev/null 2>&1; then + git fetch "$REMOTE" gh-pages + git worktree add /tmp/gh-pages FETCH_HEAD + cd /tmp/gh-pages + git checkout -B gh-pages + else + mkdir -p /tmp/gh-pages + cd /tmp/gh-pages + git init -q -b gh-pages + fi + + # zahodit staré soubory (kromě .git) a nakopírovat nový build + find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + + cp -a "${GITHUB_WORKSPACE}/_site/." . + touch .nojekyll + + git add -A + if git diff --cached --quiet; then + echo "Beze změn, nic se nepublikuje." + exit 0 + fi + git commit -q -m "Built site for gh-pages (${GITHUB_SHA::7})" + git push "$REMOTE" HEAD:gh-pages