forked from J-W-CA/auto_scheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
45 lines (40 loc) · 1.77 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
stages: # List of stages for jobs, and their order of execution
- build
- deploy
build-job: # This job runs in the build stage, which runs first.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- apk add --update jq && rm -rf /var/cache/apk/*
- export APP_ID=$(jq -r '.appId' ./app/config.json)
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- "docker build -t gitlab.thkma.com:5050/dx/${APP_ID}:${CI_COMMIT_SHORT_SHA} --build-arg NPM_TOKEN=${CI_JOB_TOKEN} ."
- echo $APP_ID
- echo $CI_COMMIT_SHORT_SHA
- echo $CI_JOB_TOKEN
- echo $CI_REGISTRY_USER
- "docker push gitlab.thkma.com:5050/dx/${APP_ID}:${CI_COMMIT_SHORT_SHA}"
deploy-job:
stage: deploy
image:
name: node:16-alpine
entrypoint: [""]
only:
- main
environment: production
before_script:
- apk add --update jq && rm -rf /var/cache/apk/*
- export APP_ID=$(jq -r '.appId' ./app/config.json)
script:
- echo "Deploying prod application..."
- echo -e "@dx:registry=https://gitlab.thkma.com/api/v4/packages/npm/\n//gitlab.thkma.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}\n//gitlab.thkma.com/api/v4/projects/:_authToken=${CI_JOB_TOKEN}" > .npmrc
- npx --yes @dx/cli@latest deploy --config=./app/config.json --image=gitlab.thkma.com:5050/dx/${APP_ID}:latest
- echo "Application successfully deployed."