fradrive/.gitlab-ci.yml
2021-09-16 12:15:57 +02:00

137 lines
3.6 KiB
YAML

workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
when: always
- when: never
default:
image:
name: nixpkgs/nix-flakes:nixos-21.05
variables:
NIX_PATH: "nixpkgs=http://nixos.org/channels/nixos-21.05/nixexprs.tar.xz"
AWS_SHARED_CREDENTIALS_FILE: "/etc/aws/credentials"
stages:
- frontend:build
- backend:build
- docker:build
node dependencies:
stage: frontend:build
script:
- nix -L build -o result .#uniworxNodeDependencies
- nix-store --export $(nix-store -qR result) > node-dependencies.nar
before_script: &nix-before
- install -m 0644 .gitlab-ci/nix-bootstrap.conf /etc/nix/nix.conf
- .gitlab-ci/write-minio-creds.sh
- .gitlab-ci/make-minio-bucket.sh
- nix-env -f .gitlab-ci/patched-nix.nix -iE 'f: f {}'
- cp -pr --reflink=auto -L .gitlab-ci/upload-to-cache.sh /etc/nix/upload-to-cache.sh
- install -m 0644 .gitlab-ci/nix.conf /etc/nix/nix.conf
- git config --global init.defaultBranch master
- install -v -m 0700 -d ~/.ssh
- install -v -T -m 0644 "${SSH_KNOWN_HOSTS}" ~/.ssh/known_hosts
- install -v -T -m 0400 "${SSH_DEPLOY_KEY}" ~/.ssh/deploy && echo "IdentityFile ~/.ssh/deploy" >> ~/.ssh/config;
- install -v -T -m 0644 "${FONTAWESOME_NPM_AUTH_FILE}" /etc/fontawesome-token
artifacts:
paths:
- node-dependencies.nar
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
well known:
stage: frontend:build
script:
- nix-store --import <node-dependencies.nar
- nix -L build -o result .#uniworxWellKnown
- nix-store --export $(nix-store -qR result) > well-known.nar
before_script: *nix-before
needs:
- job: node dependencies
artifacts: true
artifacts:
paths:
- well-known.nar
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
frontend:
stage: frontend:build
script:
- nix-store --import <node-dependencies.nar
- nix-store --import <well-known.nar
- nix -L build -o result .#uniworxFrontend
- nix-store --export $(nix-store -qR result) > frontend.nar
before_script: *nix-before
needs:
- job: node dependencies
artifacts: true
- job: well known
artifacts: true
artifacts:
paths:
- frontend.nar
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
backend:
stage: backend:build
script:
- nix-store --import <frontend.nar
- nix -L build -o result .#uniworxBackend
- cp -pr --reflink=auto -L result/bin .
before_script: *nix-before
needs:
- job: frontend
artifacts: true
artifacts:
paths:
- bin/
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
demo docker:
stage: docker:build
script:
- nix-store --import <backend.nar
- nix -L build -o result .#uniworxDemoDocker
- cp -pr --reflink=auto -L result uniworx-demo.tar.gz
before_script: *nix-before
needs:
- job: backend
artifacts: true
artifacts:
paths:
- uniworx-demo.tar.gz
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
docker:
stage: docker:build
script:
- nix-store --import <backend.nar
- nix -L build -o result .#uniworxDocker
- cp -pr --reflink=auto -L result uniworx.tar.gz
before_script: *nix-before
needs:
- job: backend
artifacts: true
artifacts:
paths:
- uniworx.tar.gz
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true