From 4be3316c1029f2732fa36945ff9a8fd164b3acbd Mon Sep 17 00:00:00 2001 From: daudix Date: Mon, 22 Jul 2024 22:22:58 +0000 Subject: [PATCH] Add Zola example (#53) An example workflow to push pages built with [Zola](https://www.getzola.org) to Codeberg Pages. Reviewed-on: https://codeberg.org/Codeberg-CI/examples/pulls/53 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: daudix Co-committed-by: daudix --- Zola/.woodpecker.yaml | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Zola/.woodpecker.yaml diff --git a/Zola/.woodpecker.yaml b/Zola/.woodpecker.yaml new file mode 100644 index 0000000..4472760 --- /dev/null +++ b/Zola/.woodpecker.yaml @@ -0,0 +1,53 @@ +# Takes a repository with Zola source, generates the static site and +# pushes the result to the pages branch of the same repository +# +# Must be set in Woodpecker configuration: +# mail: Your email address used by Codeberg +# codeberg_token: Codeberg access token with "write:repository" permission +# +# .domains file can be put inside static folder in Zola source +# + +# Exclude the pipeline to run on the pages branch +when: + branch: + exclude: pages + +# Clone recursively to fully clone the themes given as Git submodules +clone: + git: + image: woodpeckerci/plugin-git + settings: + recursive: true + +steps: + # Build Zola static files + build: + image: alpine:edge + commands: + - apk add zola + - zola build + when: + event: [push, pull_request] + + publish: + image: bitnami/git + secrets: [mail, codeberg_token] + commands: + # Configure Git + - git config --global user.email $MAIL + - git config --global user.name "Woodpecker CI" + # Clone the output branch + - git clone --branch pages https://$CODEBERG_TOKEN@codeberg.org/$CI_REPO.git $CI_REPO_NAME + # Enter the output branch + - cd $CI_REPO_NAME + # Remove old files + - git rm -r "*" || true # Don't fail if there's nothing to remove + # Copy the output of the build step + - cp -ar ../public/. . + # Commit and push all static files with the source commit hash + - git add --all + - git commit -m "Woodpecker CI ${CI_COMMIT_SHA} [SKIP CI]" --allow-empty + - git push + when: + event: [push]