This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
111 lines (100 loc) · 2.57 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
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
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
CONTAINER_NAME: $CI_REGISTRY/your-gitlab-project-path
CONTAINER_NAME_HEROKU: registry.heroku.com/$APP_NAME/web
stages:
- Build Artifacts
- Prepare Docker Images
- Deploy Application
.Build Vue App: &build
image: node:12.6.0-stretch
stage: Build Artifacts
cache:
paths:
- .yarncache
script:
- yarn install --peer --progress=false --cache-folder .yarncache
- echo $AUTH0_CONFIG_JSON >> ./auth0_config.json
- yarn vue-cli-service build --mode $BUILD_MODE
artifacts:
expire_in: 1 week
paths:
- dist
Build Vue App (Development):
<<: *build
variables:
BUILD_MODE: development
except:
- tags
Build Vue App (Production):
<<: *build
variables:
BUILD_MODE: production
only:
- tags
.Push To Registry: &push-docker
stage: Prepare Docker Images
image: docker:stable
services:
- docker:dind
script:
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker build -t $CONTAINER_NAME:$IMAGE_TAG .
- docker push $CONTAINER_NAME:$IMAGE_TAG
Push image to Registry:
<<: *push-docker
variables:
IMAGE_TAG: development
dependencies:
- Build Vue App (Development)
needs:
- Build Vue App (Development)
except:
- tags
Push tag image:
<<: *push-docker
variables:
IMAGE_TAG: $CI_COMMIT_REF_SLUG
dependencies:
- Build Vue App (Production)
needs:
- Build Vue App (Production)
only:
- tags
.Deploy to Heroku: &deploy-heroku
stage: Deploy Application
image: docker:stable
services:
- docker:dind
before_script:
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker pull $CONTAINER_NAME:$IMAGE_TAG
script:
- echo "$HEROKU_API_KEY" | docker login -u _ --password-stdin registry.heroku.com
- docker tag $CONTAINER_NAME:$IMAGE_TAG $CONTAINER_NAME_HEROKU
- docker push $CONTAINER_NAME_HEROKU
- docker run -e HEROKU_API_KEY=$HEROKU_API_KEY wingrunr21/alpine-heroku-cli:latest container:release web -a $APP_NAME
Deploy to Development:
<<: *deploy-heroku
environment: development
variables:
IMAGE_TAG: development
APP_NAME: "app-name-for-development"
needs:
- Build Vue App (Development)
- Push image to Registry
except:
- tags
Deploy to Production:
<<: *deploy-heroku
environment: production
variables:
IMAGE_TAG: $CI_COMMIT_REF_SLUG
APP_NAME: "app-name-for-production"
needs:
- Build Vue App (Production)
- Push tag image
only:
- tags
when: manual