-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
84 lines (77 loc) · 2.23 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
variables:
DOCKER_HOST: unix:///var/run/docker.sock
GCS_BUCKET: sizer.ocs.ninja
GCS_PROJECT: apt-quarter-272014
APK_CACHE_DIR: $CI_PROJECT_DIR/.cache/apk
default:
image:
name: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
artifacts:
paths:
- "*.html"
- build/
expire_in: 1 month
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- node_modules/**
- .cache/apk/**
- .npm/
policy: pull
before_script:
- apk --cache-dir "$APK_CACHE_DIR" add -u npm
stages:
- install_dependencies
- test
- build
- deploy
install_dependencies:
stage: install_dependencies
script:
- mkdir -p "$APK_CACHE_DIR" "$CI_PROJECT_DIR/.npm"
- apk --cache-dir "$APK_CACHE_DIR" add -u npm
- cd "$CI_PROJECT_DIR"
- npm ci --cache "$CI_PROJECT_DIR/.npm" --prefer-offline
only:
changes:
- package-lock.json
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- node_modules/**
- .cache/apk/**
- .npm/
policy: pull-push
# Block default script
before_script: []
eslint:
stage: test
script:
- npm run lint
unitTest:
stage: test
script:
- npm test
coverage: /All\sfiles.*?\s+(\d+.\d+)/
build:
stage: build
script:
- if [[ "$CI_COMMIT_BRANCH" == "develop" ]]; then PRE_BUILD="beta"; fi
- npm run ${PRE_BUILD}build-upstream
push-to-google-storage:
stage: deploy
only:
- main
- develop
script:
- ls -al && ls -al build
- echo -n "${GCS_SA_KEY}" | base64 -d > /tmp/key.json
- /google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/key.json --project="${GCS_PROJECT}"
- rm /tmp/key.json
- if [[ "$CI_COMMIT_BRANCH" == "develop" ]]; then GCP_DIR="beta/"; fi
- /google-cloud-sdk/bin/gsutil -m cp -r "${CI_PROJECT_DIR}/*.html" "gs://${GCS_BUCKET}/${GCP_DIR}"
- /google-cloud-sdk/bin/gsutil -m cp -r "${CI_PROJECT_DIR}/build/*" "gs://${GCS_BUCKET}/${GCP_DIR}"
# Make all files public
- /google-cloud-sdk/bin/gsutil -m acl set -r "${CI_PROJECT_DIR}/gsutil-public.json" "gs://${GCS_BUCKET}/${GCP_DIR}**"
# Make the redhat specific file only accessible for the Red Hat domain
- /google-cloud-sdk/bin/gsutil -m acl set -r "${CI_PROJECT_DIR}/gsutil-redhat.json" "gs://${GCS_BUCKET}/**/redhat.js"