-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yaml
135 lines (116 loc) · 2.88 KB
/
.gitlab-ci.yaml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
workflow:
# Only create a pipeline for specific events
# https://docs.gitlab.com/ee/ci/jobs/job_control.html
rules:
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == 'main'
changes:
- "packages/**/src"
when: always
- if: $CI_PIPELINE_SOURCE == 'trigger' || $CI_PIPELINE_SOURCE == 'web'
when: always
#############
# VARIABLES #
#############
# Prefix Legend
# CI_: Predefined GitLab CI variables
# PS_: Variables defined on GitLab Pipeline Settings
# TF_: Variables defined in this file
variables:
TF_CONTAINERFILE_DIR: ".pipeline/containerfiles"
TF_SCRIPT_DIR: ".pipeline/scripts"
##############
# JOB STAGES #
##############
stages:
- init
- test
- build
- deploy
#################
# JOB TEMPLATES #
#################
###############
# JOBS - INIT #
###############
init:
stage: init
before_script:
# Make pipeline scripts executable
- chmod +x .pipeline/scripts/*.sh
script:
- bash .pipeline/scripts/init-environment.sh
- >
podman secret create \
--env="true" \
--replace \
frontend-cf-api-key \
PS_FRONTEND_CF_API_KEY
tags:
- shell-executor
###############
# JOBS - TEST #
###############
################
# JOBS - BUILD #
################
build-backend:
stage: build
script:
- >
podman build \
--tag="registry.gitlab.com/8coretech/limitless-va-pro/backend:$CI_COMMIT_SHORT_SHA" \
--target="backend" \
.
- podman push registry.gitlab.com/8coretech/limitless-va-pro/backend:$CI_COMMIT_SHORT_SHA
tags:
- shell-executor
build-frontend-preview:
stage: build
# Reuse layer cache
needs:
- build-backend
when: manual
script:
- >
podman build \
--volume="$PS_FRONTEND_ENV_FILE_PREVIEW:/build/@frontend/.env" \
--tag="registry.gitlab.com/8coretech/limitless-va-pro/frontend-preview:$CI_COMMIT_SHORT_SHA" \
--target="frontend" \
.
- podman push registry.gitlab.com/8coretech/limitless-va-pro/frontend-preview:$CI_COMMIT_SHORT_SHA
tags:
- shell-executor
build-frontend-prod:
stage: build
# Reuse layer cache
needs:
- build-backend
when: manual
script:
- >
podman build \
--volume="$PS_FRONTEND_ENV_FILE_PROD:/build/@frontend/.env" \
--tag="registry.gitlab.com/8coretech/limitless-va-pro/frontend-prod:$CI_COMMIT_SHORT_SHA" \
--target="frontend" \
.
- podman push registry.gitlab.com/8coretech/limitless-va-pro/frontend-prod:$CI_COMMIT_SHORT_SHA
tags:
- shell-executor
#################
# JOBS - DEPLOY #
#################
# deploy-frontend-prod:
# stage: deploy
# needs:
# - build-frontend
# script:
# - >
# podman run \
# --rm \
# --interactive \
# --tty \
# --secret="" \
# --secret="" \
# registry.gitlab.com/8coretech/limitless-va-pro/frontend:$CI_COMMIT_SHORT_SHA
# tags:
# - shell-executor