fix(gitlab-ci): 💚 fix issue relating to container entrypoint stuff

Also in this commit, we improved the build script to
use the virtualenv setup we did to isolate dependencies from the rest
of the build system. We also did
some adjustments on caching deps to speed up the CI.

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@gmail.com>
This commit is contained in:
Andrei Jiroh Halili 2023-03-27 15:29:38 +00:00
parent 3b92600c23
commit eab9ae94a6
2 changed files with 32 additions and 17 deletions

View file

@ -1,9 +1,8 @@
image: image:
name: dock.mau.dev/ajhalili2006/tildeverse-web/build-ci name: dock.mau.dev/ajhalili2006/tildeverse-web/build-ci
entrypoint: entrypoint:
- /bin/sh - sh
.build-configs:
variables: variables:
FF_ENABLE_COMMIT_DATA: "true" FF_ENABLE_COMMIT_DATA: "true"
FF_GENERATE_SOCIAL_CARDS: "true" FF_GENERATE_SOCIAL_CARDS: "true"
@ -11,9 +10,9 @@ image:
.setupkit: .setupkit:
before_script: before_script:
- apk add curl gnupg - apk add curl gnupg bash coreutils
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
- (curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh || wget -t 3 -qO- https://cli.doppler.com/install.sh) | sudo sh - (curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh || wget -t 3 -qO- https://cli.doppler.com/install.sh) | sh
stages: stages:
- build - build
@ -21,19 +20,20 @@ stages:
- deploy - deploy
build:main: build:main:
extends: [ .build-configs ] extends: [ .setupkit ]
stage: build stage: build
script: script:
- mkdocs build - bash ./build.sh
artifacts: artifacts:
paths: paths:
- public - public
untracked: false untracked: false
when: on_success when: on_success
expire_in: "30 days" expire_in: "21 days"
cache: cache:
paths: paths:
- .cache - .cache
- .venv
key: pages-build-main key: pages-build-main
rules: rules:
- if: $CI_COMMIT_BRANCH == 'main' - if: $CI_COMMIT_BRANCH == 'main'
@ -44,10 +44,20 @@ build:main:
deploy:main: deploy:main:
stage: deploy stage: deploy
extends: [ .setupkit, .build-configs ] extends: [ .setupkit ]
needs: needs:
- build:main - build:main
script: script:
- apk add nodejs-lts npm - apk add nodejs-lts npm && npm i
- ls -Al - ls -Al
- doppler run -- echo hi - doppler run -- echo hi
cache:
paths:
- node_modules
key: deploykit-main
rules:
- if: $CI_COMMIT_BRANCH == 'main'
changes:
- mkdocs.yml
- markdown/*
- markdown/**/*

View file

@ -1,10 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -xe set -xe
TARGET_DIR=${TARGET_DIR:-"$HOME/public_html"} TARGET_DIR=${TARGET_DIR:-"$PWD/public"}
FF_OFFLINE_MKDOCS_PLUGIN=${FF_OFFLINE_MKDOCS_PLUGIN:-"false"} FF_OFFLINE_MKDOCS_PLUGIN=${FF_OFFLINE_MKDOCS_PLUGIN:-"false"}
FF_ENABLE_COMMIT_DATA=${FF_ENABLE_COMMIT_DATA:-"true"}
FF_GENERATE_SOCIAL_CARDS=${FF_GENERATE_SOCIAL_CARDS:-"true"}
pip3 install -r requirements.txt --user if [[ ! -d "$PWD/.venv" ]]; then
mkdocs build -d $TARGET_DIR python3 -m venv $PWD/.venv
fi
$PWD/.venv/bin/pip3 install -r requirements.txt --upgrade
$PWD/.venv/bin/mkdocs build -d $TARGET_DIR
set +xe set +xe