Merge branch 'ci-rework' into 'main'
Simplify GitLab CI, do everything in one step, switch to manual review apps See merge request soapbox-pub/soapbox!3167
This commit is contained in:
commit
e55743ffdd
101
.gitlab-ci.yml
101
.gitlab-ci.yml
|
@ -1,86 +1,27 @@
|
|||
image: node:21
|
||||
|
||||
variables:
|
||||
NODE_ENV: test
|
||||
DS_EXCLUDED_ANALYZERS: gemnasium-python
|
||||
image: node:22
|
||||
|
||||
default:
|
||||
interruptible: true
|
||||
|
||||
cache: &cache
|
||||
key:
|
||||
files:
|
||||
- yarn.lock
|
||||
paths:
|
||||
- node_modules/
|
||||
policy: pull
|
||||
|
||||
stages:
|
||||
- deps
|
||||
- test
|
||||
- build
|
||||
- deploy
|
||||
- release
|
||||
|
||||
deps:
|
||||
stage: deps
|
||||
script: yarn install --ignore-scripts
|
||||
only:
|
||||
changes:
|
||||
- yarn.lock
|
||||
cache:
|
||||
<<: *cache
|
||||
policy: push
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
script: yarn lint
|
||||
only:
|
||||
changes:
|
||||
- "**/*.js"
|
||||
- "**/*.jsx"
|
||||
- "**/*.cjs"
|
||||
- "**/*.mjs"
|
||||
- "**/*.ts"
|
||||
- "**/*.tsx"
|
||||
- "**/*.scss"
|
||||
- "**/*.css"
|
||||
- ".eslintignore"
|
||||
- ".eslintrc.json"
|
||||
- ".stylelintrc.json"
|
||||
|
||||
build:
|
||||
stage: test
|
||||
stage: build
|
||||
before_script:
|
||||
- yarn install --ignore-scripts
|
||||
- apt-get update -y && apt-get install -y zip
|
||||
script:
|
||||
- yarn build
|
||||
- yarn lint
|
||||
- yarn i18n && git diff --quiet || (echo "Locale files are out of date. Please run `yarn i18n`" && exit 1)
|
||||
- NODE_ENV=production yarn build
|
||||
- cp dist/index.html dist/404.html
|
||||
- cd dist && zip -r ../soapbox.zip . && cd ..
|
||||
variables:
|
||||
NODE_ENV: production
|
||||
artifacts:
|
||||
paths:
|
||||
- soapbox.zip
|
||||
|
||||
i18n:
|
||||
stage: test
|
||||
script:
|
||||
- yarn i18n
|
||||
- git diff --quiet || (echo "Locale files are out of date. Please run `yarn i18n`" && exit 1)
|
||||
|
||||
docs-deploy:
|
||||
stage: deploy
|
||||
image: alpine:latest
|
||||
before_script:
|
||||
- apk add curl
|
||||
script:
|
||||
- curl -X POST -F"token=$CI_JOB_TOKEN" -F'ref=master' https://gitlab.com/api/v4/projects/15685485/trigger/pipeline
|
||||
only:
|
||||
variables:
|
||||
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
|
||||
changes:
|
||||
- "docs/**/*"
|
||||
|
||||
review:
|
||||
stage: deploy
|
||||
environment:
|
||||
|
@ -92,6 +33,7 @@ review:
|
|||
- unzip soapbox.zip -d dist
|
||||
- npx -y surge dist $CI_COMMIT_REF_SLUG.git.soapbox.pub
|
||||
allow_failure: true
|
||||
when: manual
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
|
@ -108,30 +50,3 @@ pages:
|
|||
only:
|
||||
variables:
|
||||
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
|
||||
|
||||
docker:
|
||||
stage: deploy
|
||||
image: docker:25.0.3
|
||||
services:
|
||||
- docker:25.0.3-dind
|
||||
tags:
|
||||
- dind
|
||||
# https://medium.com/devops-with-valentine/how-to-build-a-docker-image-and-push-it-to-the-gitlab-container-registry-from-a-gitlab-ci-pipeline-acac0d1f26df
|
||||
script:
|
||||
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
|
||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
interruptible: false
|
||||
|
||||
release:
|
||||
stage: release
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- npx tsx ./scripts/do-release.ts
|
||||
interruptible: false
|
||||
|
||||
include:
|
||||
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
|
||||
|
|
Loading…
Reference in New Issue