saiblog/.gitlab-ci.yml

83 lines
1.9 KiB
YAML

# Pipeline for saiblog
# inspired by https://git.shivering-isles.com/shivering-isles/blog/-/blob/deploy/.gitlab-ci.yml
image: quay.io/sheogorath/build-ah-engine:latest
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- package
- test
- deploy
build:
image: docker.io/library/node:20.5
stage: build
interruptible: true
before_script:
- npm install -g pnpm
- pnpm config set store-dir .pnpm-store
script:
- pnpm install # install dependencies
- pnpm run build
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
artifacts:
untracked: true
exclude: !dist/**
paths:
- dist
expire_in: 1 week
package:
stage: package
interruptible: true
image: quay.io/sheogorath/build-ah-engine:latest
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
variables:
LANG: C.UTF-8
tags:
- privileged-ram-4gb
before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- podman build --pull -f .docker/Dockerfile -t "$CI_REGISTRY_IMAGE" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- podman push "$CI_REGISTRY_IMAGE"
- podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
test:
stage: test
interruptible: true
tags:
- privileged-ram-4gb
image: quay.io/sheogorath/build-ah-engine:latest
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
variables:
LANG: C.UTF-8
before_script:
- dnf install curl
script:
- podman run -d -p 8080:80 --name testing $CI_REGISTRY_IMAGE:latest
- sleep 5
- podman exec testing nginx -c /etc/nginx/nginx.conf -t
- curl http://localhost:8080/status.txt | grep -q 'OK'
- podman stop testing
- podman rm testing
deploy:
stage: deploy
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
variables:
PLAYBOOK: static_websites.yml
trigger:
project: saibotk.de/infrastructure-private
strategy: depend