-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (63 loc) · 2.3 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
name: CI
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
jobs:
consumer-verification:
name: Run consumer contract tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Node.js environment
uses: actions/setup-node@v3
with:
cache: npm
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm install
- name: Run Contract Tests
if: ${{ success() }}
run: npm run test:contract-consumer
- name: Publish Contract Tests
env:
APP_VERSION: ${{ github.sha }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_API_TOKEN }}
if: ${{ success() }}
run: npm run test:contract:publish -- --consumer-app-version=${APP_VERSION} --broker-token=${PACT_BROKER_TOKEN} --branch=${{ github.head_ref || github.ref_name }}
deploy-check:
needs: [consumer-verification]
name: deploy Check
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Node.js environment
uses: actions/setup-node@v3
with:
cache: npm
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm install
- name: Can I deploy?
env:
PACT_BROKER_TOKEN: ${{ secrets.PACT_API_TOKEN }}
run: |
npm run test:contract:can-i-deploy -- --version ${{ github.sha }} --broker-token=${PACT_BROKER_TOKEN} --to-environment 'production' --retry-while-unknown=15 --retry-interval=60
- name: Record Deployment in Pact from main branches
env:
APP_NAME: 'MyTestConsumer'
APP_VERSION: ${{ github.sha }}
APP_BRANCH: ${{ github.head_ref || github.ref_name }}
APP_DEPLOYMENT_ENVIRONMENT: 'production'
PACT_BROKER_TOKEN: ${{ secrets.PACT_API_TOKEN }}
if: (github.event_name == 'push' && (github.head_ref || github.ref_name) == 'master')
run: |
npm run test:contract:record:deployment -- --pacticipant ${APP_NAME} --version ${APP_VERSION} --environment ${APP_DEPLOYMENT_ENVIRONMENT} --broker-token=${PACT_BROKER_TOKEN}