-
Notifications
You must be signed in to change notification settings - Fork 4
90 lines (84 loc) · 2.86 KB
/
consumer-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
name: Consumer pipeline
on:
push:
paths-ignore:
- "provider-clients-service/**"
workflow_dispatch:
env:
PACT_BROKER_BASE_URL: https://paulogoncalves.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
jobs:
test-contract-consumer:
runs-on: ubuntu-22.04
name: Run consumer contract test
steps:
- name: Project checkout
uses: actions/checkout@v2
- run: docker-compose build consumer-test-contract
- name: Run consumer contract test
run: make consumer-test-contract
- run: docker pull pactfoundation/pact-cli:0.50.0.14
- name: Publish contract test result
run: |
docker run --rm \
-w ${PWD} \
-v ${PWD}:${PWD} \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
-e GITHUB_REF \
-e GITHUB_HEAD_REF \
pactfoundation/pact-cli:0.50.0.14 \
publish \
${PWD}/consumer-frontend/pacts \
--consumer-app-version ${{ github.sha }} \
--auto-detect-version-properties
# Runs on branches as well, so we know the status of our PRs
can-i-deploy-to-production:
runs-on: ubuntu-22.04
needs: test-contract-consumer
name: Can deploy consumer to 'production'?
steps:
- uses: actions/checkout@v2
- run: docker pull pactfoundation/pact-cli:0.50.0.14
- name: Can I deploy to production?
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
pactfoundation/pact-cli:0.50.0.14 \
broker can-i-deploy \
--pacticipant frontend \
--version ${{ github.sha }} \
--retry-while-unknown 30 \
--retry-interval 10 \
--to-environment production
# Only deploy from main
deploy:
if: github.ref == 'refs/heads/main'
needs: can-i-deploy-to-production
runs-on: ubuntu-22.04
name: Deploy consumer to 'production'
steps:
- uses: actions/checkout@v2
- name: Deploy
run: |
echo "\n========== STAGE: deploy ==========\n"
echo "Deploying to production"
echo "\n========== Deploy finished ==========\n"
associate-consumer-application-version-with-production:
needs: deploy
runs-on: ubuntu-22.04
name: Associate consumer application version with 'production'
steps:
- uses: actions/checkout@v2
- run: docker pull pactfoundation/pact-cli:0.50.0.14
- name: Associate consumer application version with 'production' environment
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
pactfoundation/pact-cli:0.50.0.14 \
broker record-deployment \
--pacticipant frontend \
--version ${{ github.sha }} \
--environment production