-
-
Notifications
You must be signed in to change notification settings - Fork 12
88 lines (73 loc) · 2.29 KB
/
contract-testing.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
name: Continuous Delivery
on:
workflow_dispatch:
push:
env:
PACT_BROKER_BASE_URL: https://paulogoncalves.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
jobs:
test-contract:
runs-on: ubuntu-latest
steps:
- name: Project checkout
uses: actions/checkout@v3
- name: Node.js Setup
uses: actions/setup-node@v3
- name: Installation of Node.js dependencies
run: npm ci
- name: Run contract test
run: npm run test:contract
- run: docker pull pactfoundation/pact-cli:latest
- name: Publish contract test result
run: |
docker run --rm \
-w ${PWD} \
-v ${PWD}:${PWD} \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
pactfoundation/pact-cli \
publish \
${PWD}/pacts \
--consumer-app-version ${{ github.sha }} \
--tag-with-git-branch
# Runs on branches as well, so we know the status of our PRs
can-i-deploy-to-production:
runs-on: ubuntu-latest
needs: test-contract
steps:
- uses: actions/checkout@v3
- run: docker pull pactfoundation/pact-cli:latest
- name: Can I deploy to production?
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
pactfoundation/pact-cli \
broker can-i-deploy \
--pacticipant Front \
--version ${{ github.sha }} \
--retry-while-unknown 30 \
--retry-interval 10 \
--to production
# Only deploy from main
deploy:
if: github.ref == 'refs/heads/main'
needs: can-i-deploy-to-production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy
run: |
echo "\n========== STAGE: deploy ==========\n"
echo "Deploying to prod"
- run: docker pull pactfoundation/pact-cli:latest
- name: Tag the pact contract with 'production' tag
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
pactfoundation/pact-cli \
broker create-version-tag \
--pacticipant Front \
--version ${{ github.sha }} \
--tag production