-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
82 lines (75 loc) · 2.03 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
services:
- docker:dind
stages:
- test
- build
- deploy
# Run flake8 to check for code quality
lint-test-job:
image: python:3-bullseye
stage: test
script:
- pip install flake8
- flake8 api
# Run the unit tests
api-unit-tests-job:
image: python:3-bullseye
stage: test
needs:
- lint-test-job
script:
- cd api
- pip install -r requirements.txt
- python -m pytest
variables:
DATABASE_URL: "postgresql://example_user:secret@mar-10-pt-thrivetogetherdb-service.default.svc.cluster.local/postgres"
SIGNING_KEY: "MIIEvAIBADANBgkqhkiG9w0BAQEF"
# # Build API Image:
build-api-image:
stage: build
image: docker:git
variables:
GITLAB_IMAGE: ${CI_REGISTRY_IMAGE}/api
before_script:
# $CI_JOB_TOKEN is variable automatically added by Gitlab: see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token registry.gitlab.com --password-stdin
script:
- docker build --tag $GITLAB_IMAGE:latest ./api
- docker push $GITLAB_IMAGE:latest
only:
- main
# # Build the React/JavaScript front-end
build-front-end-job:
stage: build
image: node:lts-bullseye
needs:
- lint-test-job
variables:
# If either of these variables is defined in the GitLab
# CI/CD variables, that value will override the value here.
# You need to substitute in your real values for
# GROUP_NAME, PROJECT_NAME, & WEBSERVICE_NAME below.
PUBLIC_URL: https://mindful-codesquad.gitlab.io/thrive-together/
REACT_APP_API_HOST: https://mar-10-pt-thrivetogetherapi.mod3projects.com
script:
- cd ghi
- npm install
- npm run build
- cp build/index.html build/404.html
artifacts:
paths:
- ghi/build/
# Deploy the React/JavaScript front-end to GitLab pages
pages:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
dependencies:
- build-front-end-job
needs:
- build-front-end-job
script:
- mv ghi/build/ public
artifacts:
paths:
- public