Skip to content

Commit 8a26da7

Browse files
daudixKeats
authored andcommitted
Add documentation on deploying to Codeberg Pages (#2584)
1 parent 1cc3ad3 commit 8a26da7

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
+++
2+
title = "Codeberg Pages"
3+
weight = 50
4+
+++
5+
6+
We are going to use the Woodpecker CI hosted by Codeberg to host the site on Codeberg Pages.
7+
8+
## Configuring your repository
9+
10+
It is required that you create a repository on Codeberg that contains only your Zola project. The [Zola directory structure](https://www.getzola.org/documentation/getting-started/directory-structure/) should be in the root of your repository.
11+
12+
Information on how to create and manage a repository on Codeberg can be found at <https://docs.codeberg.org/getting-started/first-repository/>.
13+
14+
## Ensuring that Woodpecker CI can access your theme
15+
16+
Depending on how you added your theme, your repository may not contain it. The best way to ensure that the theme is added is to use submodules. Make sure you use the `https` version of the URL.
17+
18+
```bash
19+
git submodule add <theme_url> themes/<theme_name>
20+
```
21+
22+
For example, this could look like:
23+
24+
```bash
25+
git submodule add https://github.com/getzola/hyde.git themes/hyde
26+
```
27+
28+
## Setting up Woodpecker CI
29+
30+
Assuming you have access to [Codeberg's Woodpecker CI](https://docs.codeberg.org/ci/), we can build the site and automatically deploy it to [Codeberg Pages](https://codeberg.page) on every commit.
31+
32+
First, place the following sample [Zola CI file](https://codeberg.org/Codeberg-CI/examples/src/branch/main/Zola/.woodpecker.yaml) in the root of your project:
33+
34+
```yaml
35+
# Exclude the pipeline to run on the pages branch
36+
when:
37+
branch:
38+
exclude: pages
39+
40+
# Clone recursively to fully clone the themes given as Git submodules
41+
clone:
42+
git:
43+
image: woodpeckerci/plugin-git
44+
settings:
45+
recursive: true
46+
47+
steps:
48+
# Build Zola static files
49+
build:
50+
image: alpine:edge
51+
commands:
52+
- apk add zola
53+
- zola build
54+
when:
55+
event: [push, pull_request]
56+
57+
publish:
58+
image: bitnami/git
59+
secrets: [mail, codeberg_token]
60+
commands:
61+
# Configure Git
62+
- git config --global user.email $MAIL
63+
- git config --global user.name "Woodpecker CI"
64+
# Clone the output branch
65+
- git clone --branch pages https://[email protected]/$CI_REPO.git $CI_REPO_NAME
66+
# Enter the output branch
67+
- cd $CI_REPO_NAME
68+
# Remove old files
69+
- git rm -r "*" || true # Don't fail if there's nothing to remove
70+
# Copy the output of the build step
71+
- cp -ar ../public/. .
72+
# Commit and push all static files with the source commit hash
73+
- git add --all
74+
- git commit -m "Woodpecker CI ${CI_COMMIT_SHA} [SKIP CI]" --allow-empty
75+
- git push
76+
when:
77+
event: [push]
78+
```
79+
80+
Then add the following secrets to [Woodpecker](https://ci.codeberg.org/):
81+
82+
- `mail`: Your email address as used by Codeberg.
83+
- `codeberg_token`: [Codeberg access token](https://docs.codeberg.org/advanced/access-token/) with `write:repository` permission.
84+
85+
Once done, you can trigger the CI by pushing something to the repository, and Woodpecker will build the site and copy the resulting site to the `pages` branch and it will be available at `https://<repository>.<user>.codeberg.page`.
86+
87+
For [custom domain](https://docs.codeberg.org/codeberg-pages/using-custom-domain/), create the `.domains` file inside the `./static/` directory so that it will be copied to the resulting build.
88+
89+
More information about Codeberg Pages is available in the [official Codeberg documentation](https://docs.codeberg.org/codeberg-pages/).

0 commit comments

Comments
 (0)