#Deploying to Gitlab Pages

11 messages · Page 1 of 1 (latest)

last wyvern
#

Im trying to deploy my site to Gitlab pages. Im able to pass the test stage, but on the deploy stage, I get "missing pages artifacts".

Ive made sure to change public to static in my structure since Gitlab looks for public.

I use pnpm to build the Astro.

Im not entirely sure why its missing artifacts.

Any help is appreciated

gitlab-ci.yml

# Docker image used to build app
image: node:lts

# Functions to be executed before build script is run
before_script:
  - corepack enable
  - corepack prepare pnpm@latest-8 --activate
  - pnpm config set store-dir .pnpm-store

pages:
  script:
    - pnpm install
  artifacts:
    paths:
    - public
  cache:
    key:
      files:
        - pnpm-lock.yaml
    paths:
      # Folder containing files to be exposed at page URL
      - public
      - .pnpm-store
  rules:
    # Ensures only pushes to default branch will trigger pages deploy
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

astro.config.ts

export default defineConfig({
  site: 'https://username.gitlab.io',
  //base: '/<project-name>',
  outDir: 'public',
  publicDir: 'static',
...
})
amber rainBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

broken bluff
#

Did you tried

pages:
  script:
    - pnpm install
    - pnpm run build

?

last wyvern
#

However, now Im getting error

Error: Pagefind wasn't able to build an index.

#

I moved back to default outDir instead of redirecting to static

#

It builds the site but still is missing pages artifacts, saying there are no pages to upload

broken bluff
#

are you using the default Astro config with src/pages ?

Have you tried to remove the cache or the yaml ?

last wyvern
# broken bluff are you using the default Astro config with src/pages ? Have you tried to remov...

Im using this theme:
https://github.com/chrismwilliams/astro-theme-cactus

This is what my astro config looks like:

import mdx from "@astrojs/mdx";
import prefetch from "@astrojs/prefetch";
import sitemap from "@astrojs/sitemap";
import tailwind from "@astrojs/tailwind";
import { defineConfig } from "astro/config";
import fs from "fs";
import remarkUnwrapImages from "remark-unwrap-images";
import { remarkReadingTime } from "./src/utils/remark-reading-time";

// https://astro.build/config
export default defineConfig({
    // ! Please remember to replace the following site property with your own domain
  site: 'https://glitchbyte.gitlab.io',
  //base: '/<project-name>',
  //outDir: 'public',
  //publicDir: 'static',
    markdown: {
        remarkPlugins: [remarkUnwrapImages, remarkReadingTime],
        remarkRehype: { footnoteLabelProperties: { className: [""] } },
        shikiConfig: {
            theme: "dracula",
            wrap: true,
        },
    },
    integrations: [
        mdx({}),
        tailwind({
            applyBaseStyles: false,
        }),
        sitemap(),
        prefetch(),
    ],
    image: {
        domains: ["webmention.io"],
    },
    vite: {
        plugins: [rawFonts([".ttf"])],
        optimizeDeps: {
            exclude: ["@resvg/resvg-js"],
        },
    },
});

function rawFonts(ext: Array<string>) {
    return {
        name: "vite-plugin-raw-fonts",
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        // @ts-ignore:next-line
        transform(_, id) {
            if (ext.some((e) => id.endsWith(e))) {
                const buffer = fs.readFileSync(id);
                return {
                    code: `export default ${JSON.stringify(buffer)}`,
                    map: null,
                };
            }
        },
    };
}

GitHub

A simple Astro theme. Use it to create your blog or website. - GitHub - chrismwilliams/astro-theme-cactus: A simple Astro theme. Use it to create your blog or website.

last wyvern
#

Got it deployed

Heres what my configs look like:

gitlab-ci.yaml

# Docker image used to build app
image: node:lts

# Functions to be executed before build script is run
before_script:
  - corepack enable
  - corepack prepare pnpm@latest-8 --activate
  - pnpm config set store-dir .pnpm-store

pages:
  script:
    - pnpm install
    - pnpm build
  artifacts:
    paths:
      - public
  cache:
    key:
      files:
        - pnpm-lock.yaml
    paths:
      # Folder containing files to be exposed at page URL
      - public
      - .pnpm-store
  rules:
    # Ensures only pushes to default branch will trigger pages deploy
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
#

astro.config.ts

export default defineConfig({
    // ! Please remember to replace the following site property with your own domain
  site: 'https://glitchbyte.gitlab.io',
  //base: '/<project-name>',
  // GitLab Pages requires exposed files to be located in a folder called "public".
  // So we're instructing Astro to put the static build output in a folder of that name.
  dist: 'public',

  // The folder name Astro uses for static files (`public`) is already reserved
  // for the build output. So in deviation from the defaults we're using a folder
  // called `static` instead.
  public: 'static',
...
})