-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
92 lines (86 loc) 路 2.48 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
92 lines (86 loc) 路 2.48 KB
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
85
86
87
88
89
90
91
92
stages:
- test
- sbom
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: '/certs'
CAPROVER_APP_NAME: 'platform'
CAPROVER_DEV_URL: 'https://captain.dev.unicis.tech'
CAPROVER_PROD_URL: 'https://captain.platform.unicis.tech'
GIT_DEPTH: 0
test:
stage: test
image: node:18.18.2
script:
- echo 'test passed'
only:
- merge_requests
except:
- tags
sbom_dev:
stage: sbom
image: node:18.18.2
script:
- npm install
- npm install -g @cyclonedx/cyclonedx-npm
- cyclonedx-npm --output-file sbom-dev.json
artifacts:
paths:
- sbom-dev.json
only:
- merge_requests
except:
- tags
sbom_prod:
stage: sbom
image: node:18.18.2
script:
- npm install
- npm install -g @cyclonedx/cyclonedx-npm
- cyclonedx-npm --output-file sbom-prod.json
artifacts:
paths:
- sbom-prod.json
only:
- tags
deploy_dev:
stage: deploy
image: node:18-bookworm
before_script:
- apt-get update && apt-get install -y openssh-client openssl
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
- chmod 600 ~/.ssh/id_ed25519
- eval "$(ssh-agent -s)" >/dev/null
- ssh-add ~/.ssh/id_ed25519
- ssh-keyscan -H "$(echo "$PLATFORM_DEV_IP" | sed 's/.*@//')" >> ~/.ssh/known_hosts 2>/dev/null || true
- git fetch origin "$CI_COMMIT_REF_NAME" || git fetch --all
- git checkout -B "$CI_COMMIT_REF_NAME" "origin/$CI_COMMIT_REF_NAME" || true
- npm install -g caprover
script:
- echo "Deploying branch $CI_COMMIT_REF_NAME"
- export SSH_AUTH_SOCK
- ssh -o StrictHostKeyChecking=accept-new -o BatchMode=yes -o IdentitiesOnly=yes root@"$PLATFORM_DEV_IP" 'cd /root/retraced && docker compose stop'
- caprover deploy --caproverUrl "$CAPROVER_DEV_URL" --caproverPassword "$CAPROVER_DEV_PASSWORD" --caproverApp "$CAPROVER_APP_NAME" --branch "$CI_COMMIT_REF_NAME"
- ssh -o StrictHostKeyChecking=accept-new -o BatchMode=yes -o IdentitiesOnly=yes root@"$PLATFORM_DEV_IP" 'cd /root/retraced && docker compose up -d'
only:
- merge_requests
except:
- tags
environment:
name: development
when: manual
deploy_prod:
stage: deploy
image: node:18-bookworm
before_script:
- git fetch --tags --prune || true
- npm install -g caprover
script:
- caprover deploy --caproverUrl "$CAPROVER_PROD_URL" --caproverPassword "$CAPROVER_PROD_PASSWORD" --caproverApp "$CAPROVER_APP_NAME" --branch main
only:
- tags
environment:
name: production