-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (54 loc) · 1.96 KB
/
pact-consumer.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
name: Pact-Consumer
on:
workflow_dispatch:
env:
PACT_FLOW_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
PACT_FLOW_TOKEN: ${{ secrets.PACTFLOW_TOKEN }}
GIT_COMMIT: ${{ github.sha }}
GIT_REF: ${{ github.ref }}
GIT_BRANCH: ${{ github.ref_name }}
CONSUMER: "bookClient"
jobs:
run_contract_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Run tests
run: ./gradlew runConsumerTest
- name: Publish Pact to Pactflow if tests pass
run: |
GIT_BRANCH=${GITHUB_REF#refs/heads/}
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_FLOW_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_FLOW_TOKEN \
-e GIT_COMMIT=$GIT_COMMIT \
-e GIT_BRANCH=$GIT_BRANCH \
-e PACT_DO_NOT_TRACK=true \
-v ${PWD}/build/pacts:/pacts \
pactfoundation/pact-cli:latest \
publish /pacts \
--consumer-app-version $GIT_COMMIT \
--branch $GIT_BRANCH \
--tag $GIT_BRANCH
- name: can-I-deploy
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_FLOW_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_FLOW_TOKEN \
pactfoundation/pact-cli:latest \
pact-broker can-i-deploy --pacticipant $CONSUMER --latest
- name: Deploy to Test
run: echo "Deploy to TEST Environment"
- name: Record Deployment for TEST
run: |
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_FLOW_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_FLOW_TOKEN \
pactfoundation/pact-cli:latest \
pact-broker record-deployment --broker-base-url=$PACT_FLOW_BASE_URL --broker-token=$PACT_FLOW_TOKEN --pacticipant $CONSUMER --version $GIT_COMMIT --environment 'test'