~hokiegeek/biologist-web

ref: 3.0.3 biologist-web/.build.yml -rw-r--r-- 2.4 KiB View raw
fa0ea1e3HokieGeek Corrected bad copypasta 9 months ago
                                                                                
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
image: archlinux
packages:
  - nodejs
  - npm
  - chromium
  - harfbuzz
  - nss
  - docker
  - shadow
  - google-cloud-sdk
sources:
  - https://git.sr.ht/~hokiegeek/biologist-web
environment:
  PROJ: biologist-web
  GCP_PROJ: hokiegeek-net
  GCP_RUN_SVC: life
  CI_COMMIT_TAG: $(git --work-tree=./biologist-web --git-dir=./biologist-web/.git describe)
  CI_REGISTRY_USER_HUB: hokiegeek
  CI_REGISTRY_GCR: gcr.io
  CI_REGISTRY_USER_GCR: hokiegeek-net
secrets:
  - 1e1af69d-4036-40fd-9eb8-03b367bdb0eb # docker hub
  - 3c7786a3-e027-4018-bc74-42a1492176d5 # gcp key
tasks:
  - docker_setup: |
      sudo mount -t tmpfs -o size=4G /dev/null /dev/shm
      sudo nohup dockerd --bip 172.18.0.1/16 </dev/null >/dev/null 2>&1 &
      sudo gpasswd -a $(whoami) docker
  - gcloud_setup: |
      gcloud auth activate-service-account --key-file=$HOME/.gcp_cloudrunner_key.json
      gcloud config set project ${GCP_PROJ}
      yes | gcloud auth configure-docker
  - install: |
      cd ${PROJ}
      npm install
  - lint: |
      cd ${PROJ}
      npm run lint
  - build: |
      cd ${PROJ}
      npm run build
      version=$(awk 'BEGIN { FS=":"; RS="," } $1 ~ /"version"/ { gsub(/( |")/, "", $0); print $2 }' package.json)
      sed -i '/^<head>$/ a\    <meta name="application-name" content="hokiegeek.net_life" data-version="'${version}${version_suffix:+":${version_suffix}"}'" />' dist/index.html
  - test: |
      export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
      export CHROME_BIN="/usr/bin/chromium-browser"
      cd ${PROJ}
      npm run test
  - package: |
      cd ${PROJ}
      IMAGE_HUB=${CI_REGISTRY_USER_HUB}/${PROJ}
      IMAGE_HUB_TAG=${IMAGE_HUB}:${CI_COMMIT_TAG}
      IMAGE_GCR=${CI_REGISTRY_GCR}/${CI_REGISTRY_USER_GCR}/${PROJ}
      IMAGE_GCR_TAG=${IMAGE_GCR}:${CI_COMMIT_TAG}
      docker build -t ${IMAGE_GCR_TAG} -t ${IMAGE_GCR}:latest -t ${IMAGE_HUB_TAG} -t ${IMAGE_HUB}:latest .
      # Docker Hub
      cat $HOME/.image_registry_token | docker login --username ${CI_REGISTRY_USER_HUB} --password-stdin
      docker push ${IMAGE_HUB_TAG}
      docker push ${IMAGE_HUB}:latest
      # GCR
      cat $HOME/.gcp_cloudrunner_key.json | docker login -u _json_key --password-stdin https://${CI_REGISTRY_GCR}
      docker push ${IMAGE_GCR_TAG}
      docker push ${IMAGE_GCR}:latest
  - deploy: |
      gcloud beta run deploy ${GCP_RUN_SVC} --image ${CI_REGISTRY_GCR}/${CI_REGISTRY_USER_GCR}/${PROJ} --platform managed --region us-east1 --allow-unauthenticated --memory 512Mi