-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (102 loc) · 3.55 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
109
110
111
# 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-frontend
GIT_COMMIT: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
AWS_COGNITO_USERNAME: ${{ secrets.AWS_COGNITO_USERNAME }}
AWS_COGNITO_PASSWORD: ${{ secrets.AWS_COGNITO_PASSWORD }}
jobs:
cypress-test:
runs-on: ubuntu-latest
steps:
- name: Check out code 🛎
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
# need this to avoid chokidar file watcher spamming the console
- run: npm ci
- name: Run E2E tests 🧪
uses: cypress-io/github-action@v2
with:
# we have already installed everything
install: false
start: npm run start:ci
wait-on: 'http://localhost:3000'
unit-and-pact-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- uses: mansona/npm-lockfile-version@v1
- run: npm ci
- run: npm run test:unit
- run: npm run test:pact
- name: Publish pact tagged with branch name
run: npx pact-broker publish ./pact/pacts --consumer-app-version ${GIT_COMMIT} --broker-base-url ${PACT_BROKER_BASE_URL} --broker-token ${PACT_BROKER_TOKEN} --tag ${GITHUB_REF:11}
lint-format-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm ci
- run: npm run prepush
- run: npm run build
can-i-deploy:
runs-on: ubuntu-latest
needs: [cypress-test, unit-and-pact-test, lint-format-build]
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