Skip to content

Commit c5973c5

Browse files
committed
fix issues with Steps component
1 parent d4558f6 commit c5973c5

File tree

1 file changed

+108
-94
lines changed

1 file changed

+108
-94
lines changed

src/content/docs/en/guides/deploy/codeberg.mdx

Lines changed: 108 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,111 +9,125 @@ type: deploy
99
import { Steps } from '@astrojs/starlight/components';
1010

1111
You can use Codeberg Pages to host your Astro site directly from a repository on Codeberg.
12+
1213
## How to deploy
14+
1315
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:
1416

17+
<Steps>
18+
1519
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+
1621
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-
export default defineConfig({
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+
export default defineConfig({
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
3241
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+
3849
3. In the repository root, create a `.forgejo` folder, and inside it create a `workflows` folder.
50+
3951
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.
55-
runs-on: codeberg-tiny-lazy
56-
steps:
57-
- name: Clone the repository
58-
uses: https://code.forgejo.org/actions/checkout@v4
59-
with:
60-
submodules: recursive
61-
fetch-depth: 0
62-
- name: check .domains files
63-
run: |
64-
git ls-files public/.domains
65-
ls -la public/
66-
ls -la public/.domains || echo ".domains not found"
67-
- name: Setup Node.js
68-
uses: https://code.forgejo.org/actions/setup-node@v4
69-
with:
70-
node-version: 22
71-
- name: Install dependencies
72-
run: npm install
73-
- name: Build Astro site
74-
run: npm run build
75-
76-
- name: Upload generated files
77-
uses: https://code.forgejo.org/actions/upload-artifact@v3
78-
with:
79-
name: Generated files
80-
path: dist/
81-
include-hidden-files: true
82-
83-
deploy:
84-
needs: [ build ]
85-
runs-on: codeberg-tiny-lazy
86-
steps:
87-
- name: Clone the repository
88-
uses: https://code.forgejo.org/actions/checkout@v4
89-
with:
90-
submodules: recursive
91-
fetch-depth: 0
92-
93-
- name: Checkout the target branch and clean it up
94-
run: |
95-
git checkout pages || git switch --orphan pages
96-
rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$')
97-
98-
- name: Download generated files
99-
uses: https://code.forgejo.org/actions/download-artifact@v3
100-
with:
101-
name: Generated files
102-
103-
- name: Publish the website
104-
run: |
105-
git config user.email codeberg-ci
106-
git config user.name "Codeberg CI"
107-
echo "=== Files being committed ==="
108-
ls -la
109-
git add .
110-
git commit --allow-empty --message "Codeberg build for ${GITHUB_SHA}"
111-
git push origin pages
112-
113-
```
52+
```yml
53+
name: Deploy Astro site to Pages
54+
55+
on:
56+
# Runs on pushes targeting the default branch
57+
push:
58+
branches:
59+
# If you want to build from a different branch, change it here.
60+
- main
61+
# Allows you to run this workflow manually from the Actions tab
62+
workflow_dispatch:
63+
64+
jobs:
65+
build:
66+
# You can find the list of available runners on https://codeberg.org/actions/meta, or run one yourself.
67+
runs-on: codeberg-tiny-lazy
68+
steps:
69+
- name: Clone the repository
70+
uses: https://code.forgejo.org/actions/checkout@v4
71+
with:
72+
submodules: recursive
73+
fetch-depth: 0
74+
- name: check .domains files
75+
run: |
76+
git ls-files public/.domains
77+
ls -la public/
78+
ls -la public/.domains || echo ".domains not found"
79+
- name: Setup Node.js
80+
uses: https://code.forgejo.org/actions/setup-node@v4
81+
with:
82+
node-version: 22
83+
- name: Install dependencies
84+
run: npm install
85+
- name: Build Astro site
86+
run: npm run build
87+
88+
- name: Upload generated files
89+
uses: https://code.forgejo.org/actions/upload-artifact@v3
90+
with:
91+
name: Generated files
92+
path: dist/
93+
include-hidden-files: true
94+
95+
deploy:
96+
needs: [ build ]
97+
runs-on: codeberg-tiny-lazy
98+
steps:
99+
- name: Clone the repository
100+
uses: https://code.forgejo.org/actions/checkout@v4
101+
with:
102+
submodules: recursive
103+
fetch-depth: 0
104+
105+
- name: Checkout the target branch and clean it up
106+
run: |
107+
git checkout pages || git switch --orphan pages
108+
rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$')
109+
110+
- name: Download generated files
111+
uses: https://code.forgejo.org/actions/download-artifact@v3
112+
with:
113+
name: Generated files
114+
115+
- name: Publish the website
116+
run: |
117+
git config user.email codeberg-ci
118+
git config user.name "Codeberg CI"
119+
echo "=== Files being committed ==="
120+
ls -la
121+
git add .
122+
git commit --allow-empty --message "Codeberg build for ${GITHUB_SHA}"
123+
git push origin pages
124+
125+
```
114126

115127
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.
116128

117129
6. Commit your changes and push to Codeberg. Codeberg will deploy automatically for you.
118130

131+
</Steps>
132+
119133
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

Comments
 (0)