You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use Codeberg Pages to host your Astro site directly from a repository on Codeberg.
12
+
12
13
## How to deploy
14
+
13
15
You can use Codeberg CI to automatically build and deploy your site, publishing your Astro site to Codeberg Pages. For this, your source code must be hosted on Codeberg, and do the following:
14
16
17
+
<Steps>
18
+
15
19
1. Open an issue [here](https://codeberg.org/Codeberg-e.V./requests/issues), tag it with `ci`, select `Expected Resource Usage` as `medium`, add your own Codeberg username in `I would also like the following users to be added`, and fill in the rest as you see fit. Wait for approval.
20
+
16
21
2. Configure the [`site`](/en/reference/configuration-reference/#site) and [`base`](/en/reference/configuration-reference/#base) settings in the `astro.config.mjs` file.
17
-
```js title="astro.config.mjs" ins={4-5}
18
-
import { defineConfig } from'astro/config';
19
-
exportdefaultdefineConfig({
20
-
site:'https://<username>.codeberg.page',
21
-
base:'/<my-repo>',
22
-
outDir:'dist',
23
-
publicDir:'public',
24
-
});
25
-
`base`
26
-
To make Astro treat your repository name (e.g., `/my-repo`) as the root directory of your website, you need a `base` value.
27
-
:::note
28
-
If your pages are served from the root directory, you don't need to set the `base` parameter.
29
-
:::
30
-
The `base` value should be your repository name starting with a slash, such as `/my-blog`. This lets Astro understand that the root of your site is `/my-repo` instead of the default `/`.
31
-
:::caution
22
+
23
+
```js title="astro.config.mjs" ins={4-5}
24
+
import { defineConfig } from'astro/config';
25
+
exportdefaultdefineConfig({
26
+
site:'https://<username>.codeberg.page',
27
+
base:'/<my-repo>',
28
+
outDir:'dist',
29
+
publicDir:'public',
30
+
});
31
+
```
32
+
33
+
To make Astro treat your repository name (e.g., `/my-repo`) as the root directory of your website, you need a `base` value.
34
+
:::note
35
+
If your pages are served from the root directory, you don't need to set the `base` parameter.
36
+
:::
37
+
38
+
The `base` value should be your repository name starting with a slash, such as `/my-blog`. This lets Astro understand that the root of your site is `/my-repo` instead of the default `/`.
39
+
40
+
:::caution
32
41
After configuring this value, all internal page links must be prefixed with your `base` value:
33
-
```astro ins="/my-repo"
34
-
<a href="/my-repo/about">About</a>
35
-
```
36
-
See [Configuring the `base` value](/en/reference/configuration-reference/#base)
37
-
:::
42
+
```astro ins="/my-repo"
43
+
<a href="/my-repo/about">About</a>
44
+
```
45
+
46
+
See [Configuring the `base` value](/en/reference/configuration-reference/#base)
47
+
:::
48
+
38
49
3. In the repository root, create a `.forgejo` folder, and inside it create a `workflows` folder.
50
+
39
51
4. In that folder, add an `astro.yaml` file. A sample of the file is as follows:
40
-
```yml
41
-
name: Deploy Astro site to Pages
42
-
43
-
on:
44
-
# Runs on pushes targeting the default branch
45
-
push:
46
-
branches:
47
-
# If you want to build from a different branch, change it here.
48
-
- main
49
-
# Allows you to run this workflow manually from the Actions tab
50
-
workflow_dispatch:
51
-
52
-
jobs:
53
-
build:
54
-
# You can find the list of available runners on https://codeberg.org/actions/meta, or run one yourself.
git commit --allow-empty --message "Codeberg build for ${GITHUB_SHA}"
123
+
git push origin pages
124
+
125
+
```
114
126
115
127
5. In the public directory, create a `.domains` file and enter `branch.repository.username.codeberg.page`—this is your default domain. If you want to add a custom domain, see this article: https://codeberg.org/Codeberg/pages-server/src/branch/main/README.md.
116
128
117
129
6. Commit your changes and push to Codeberg. Codeberg will deploy automatically for you.
118
130
131
+
</Steps>
132
+
119
133
Your site should now be publishable! When you push updates to your Astro project's repository, the Codeberg CI pipeline will automatically deploy them.
0 commit comments