-
Notifications
You must be signed in to change notification settings - Fork 3.9k
200 lines (182 loc) · 6.54 KB
/
dev-deploy-api.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Deploy DEV API
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
push:
branches:
- next
- main
paths:
- 'package.json'
- 'yarn.lock'
- 'apps/api/**'
- 'libs/dal/**'
- 'libs/shared/**'
env:
TF_WORKSPACE: novu-dev
jobs:
test_api:
strategy:
matrix:
name: ['novu/api-ee', 'novu/api']
uses: ./.github/workflows/reusable-api-e2e.yml
with:
ee: ${{ contains (matrix.name,'ee') }}
submodules: ${{ contains (matrix.name,'ee') }}
submodule_branch: "next"
secrets: inherit
test_e2e_ee:
name: Test E2E EE
runs-on: ubuntu-latest
timeout-minutes: 80
permissions:
contents: read
packages: write
deployments: write
id-token: write
steps:
- run: echo ${{ matrix.projectName }}
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
name: Lint and build
with:
targets: lint,build
projects: ${{matrix.projectName}}
- uses: ./.github/actions/start-localstack
- uses: ./.github/actions/run-worker
if: ${{matrix.projectName == '@novu/api' }}
with:
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}
- uses: mansagroup/nrwl-nx-action@v3
name: Running the E2E tests
env:
LAUNCH_DARKLY_SDK_KEY: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}
GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
CI_EE_TEST: true
with:
targets: test:e2e:ee
projects: ${{matrix.projectName}}
deploy_dev_api:
if: "!contains(github.event.head_commit.message, 'ci skip')"
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: test_api
timeout-minutes: 80
environment: Development
permissions:
contents: read
packages: write
deployments: write
id-token: write
strategy:
matrix:
name: ['novu/api-ee', 'novu/api']
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/docker/build-api
id: docker_build
with:
tag: dev
push: 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}
docker_name: ${{ matrix.name }}
bullmq_secret: ${{ secrets.BULL_MQ_PRO_NPM_TOKEN }}
- name: Checkout cloud infra
if: ${{ contains (matrix.name,'ee') }}
uses: actions/checkout@master
with:
repository: novuhq/cloud-infra
token: ${{ secrets.GH_PACKAGES }}
path: cloud-infra
- name: Configure AWS credentials
if: ${{ contains (matrix.name,'ee') }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- name: Terraform setup
if: ${{ contains (matrix.name,'ee') }}
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_version: 1.5.5
terraform_wrapper: false
- name: Terraform Init
if: ${{ contains (matrix.name,'ee') }}
working-directory: cloud-infra/terraform/novu
run: terraform init
- name: Terraform get output
if: ${{ contains (matrix.name,'ee') }}
working-directory: cloud-infra/terraform/novu
id: terraform
run: |
echo "api_ecs_container_name=$(terraform output -json api_ecs_container_name | jq -r .)" >> $GITHUB_ENV
echo "api_ecs_service=$(terraform output -json api_ecs_service | jq -r .)" >> $GITHUB_ENV
echo "api_ecs_cluster=$(terraform output -json api_ecs_cluster | jq -r .)" >> $GITHUB_ENV
echo "api_task_name=$(terraform output -json api_task_name | jq -r .)" >> $GITHUB_ENV
- name: Download task definition
if: ${{ contains (matrix.name,'ee') }}
run: |
aws ecs describe-task-definition --task-definition ${{ env.api_task_name }} \
--query taskDefinition > task-definition.json
- name: Render Amazon ECS task definition
if: ${{ contains (matrix.name,'ee') }}
id: render-web-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ env.api_ecs_container_name }}
image: ${{ steps.docker_build.outputs.image }}
- name: Deploy to Amazon ECS service
if: ${{ contains (matrix.name,'ee') }}
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-web-container.outputs.task-definition }}
service: ${{ env.api_ecs_service }}
cluster: ${{ env.api_ecs_cluster }}
wait-for-service-stability: true
- name: get-npm-version
if: ${{ contains (matrix.name,'ee') }}
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: apps/api
- name: Create Sentry release
if: ${{ contains (matrix.name,'ee') }}
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: novu-r9
SENTRY_PROJECT: api
with:
version: ${{ steps.package-version.outputs.current-version}}
environment: dev
version_prefix: v
sourcemaps: apps/api/dist
ignore_empty: true
ignore_missing: true
url_prefix: "~"
newrelic:
runs-on: ubuntu-latest
name: New Relic Deploy
needs: deploy_dev_api
environment: Development
steps:
# This step builds a var with the release tag value to use later
- name: Set Release Version from Tag
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
# This step creates a new Change Tracking Marker
- name: New Relic Application Deployment Marker
uses: newrelic/[email protected]
with:
region: EU
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
guid: "MzgxMjQwOHxBUE18QVBQTElDQVRJT058NDk3NjQzODIy"
version: "${{ env.RELEASE_VERSION }}"
user: "${{ github.actor }}"