Deploy your Astro Site to GitLab Pages
Ta treść nie jest jeszcze dostępna w Twoim języku.
You can use GitLab Pages to host an Astro site for your GitLab projects, groups, or user account.
How to deploy
Section titled How to deploy-
Set the correct
siteinastro.config.mjs. -
Rename the
public/directory tostatic. -
Set
outDir:publicinastro.config.mjs. This setting instructs Astro to put the static build output in a folder calledpublic, which is the folder required by GitLab Pages for exposed files.If you were using the
public/directory as a source of static files in your Astro project, rename it and use that new folder name inastro.config.mjsfor the value ofpublicDir.For example, here are the correct
astro.config.mjssettings when thepublic/directory is renamed tostatic/:import { defineConfig } from 'astro/config';export default defineConfig({site: 'https://<user>.gitlab.io',base: '/<project-name>',outDir: 'public',publicDir: 'static',}); -
Create a file called
.gitlab-ci.ymlin the root of your project with the content below. This will build and deploy your site whenever you make changes to your content:pages:# The Docker image that will be used to build your appimage: node:ltsbefore_script:- npm ciscript:# Specify the steps involved to build your app here- npm run buildartifacts:paths:# The folder that contains the built files to be published.# This must be called "public".- publiconly:# Trigger a new build and deploy only when there is a push to the# branch(es) below- main