diff --git a/.gitea/workflows/publish-site.yml b/.gitea/workflows/publish-site.yml new file mode 100644 index 00000000..28ae4487 --- /dev/null +++ b/.gitea/workflows/publish-site.yml @@ -0,0 +1,45 @@ +name: Build and Publish Gitea Pages + +on: + push: + branches: + # Switch to main after testing the deployment. + - feature/gitea_pages + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest-intranet + container: + image: gitea.psi.ch/images/alpine-zensical + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build site + env: + PAGES_URL: https://${{ github.repository_owner }}.pages.psi.ch/${{ github.event.repository.name }}/ + run: | + # Use the Pages URL for this build while retaining the Read the Docs config. + sed "s|^site_url = .*|site_url = \"${PAGES_URL}\"|" \ + zensical.toml > zensical.pages.toml + /opt/python-env/bin/zensical build --clean --config-file zensical.pages.toml + + - name: Publish to gitea-pages + env: + PAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PAGES_REPOSITORY: ${{ github.repository }} + run: | + # Create a separate repository containing only generated files, + # including hidden files, so source files cannot enter the Pages branch. + publish_dir=$(mktemp -d) + cp -a site/. "$publish_dir/" + cd "$publish_dir" + git init + git config user.name "Gitea Actions" + git config user.email "actions@gitea.local" + git add . + git commit -m "Update site - $(date -u)" + git push --force \ + "https://${PAGES_TOKEN}@gitea.psi.ch/${PAGES_REPOSITORY}.git" \ + HEAD:gitea-pages