-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (100 loc) · 3.48 KB
/
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
PACT_BROKER_BASE_URL: https://c4cneu.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
PACT_PACTICIPANT: jpal-backend
GIT_COMMIT: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
jobs:
test:
runs-on: ubuntu-latest
# Postgres service for E2E testing
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DATABASE: postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
JWT_SECRET: test_secret_for_CI
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# We are using Node.js 14 because it is the current LTS version
node-version: 14.x
- uses: mansona/npm-lockfile-version@v1
- run: npm ci
- run: npm run check
- run: npm run test
- run: npm run build
- run: npm run typeorm migration:run
- run: npm run test:e2e
- run: npm run test:pact
can-i-deploy:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- run: docker pull pactfoundation/pact-cli:latest
- name: Can I deploy?
run: |
docker run --rm \
pactfoundation/pact-cli:latest \
broker can-i-deploy \
--broker-base-url=${PACT_BROKER_BASE_URL} \
--broker-token ${PACT_BROKER_TOKEN} \
--pacticipant ${PACT_PACTICIPANT} \
--version ${GIT_COMMIT} \
--to prod
#TODO: write a real deploy script
deploy:
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
needs: can-i-deploy
steps:
- uses: actions/checkout@v2
- run: docker pull pactfoundation/pact-cli:latest
- name: Tag version as prod
run: |
docker run --rm \
pactfoundation/pact-cli:latest \
broker create-version-tag \
--broker-base-url=${PACT_BROKER_BASE_URL} \
--broker-token ${PACT_BROKER_TOKEN} \
--pacticipant ${PACT_PACTICIPANT} \
--version ${GIT_COMMIT} \
--tag prod
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production