-
Notifications
You must be signed in to change notification settings - Fork 16
140 lines (118 loc) · 4.5 KB
/
ci-pricing.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Pricing CI
run-name: Pricing CI
on:
push:
paths:
- 'services/Pricing/**'
- 'libs/SharedLib/**'
- '.github/workflows/ci-pricing.yml'
- '.github/workflows/ci-shared-lib.yml'
workflow_dispatch:
repository_dispatch:
types: [pricing-ci-webhook]
env:
PACT_BROKER_BASE_URL: ${{ vars.PACT_BROKER_BASE_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
PACTICIPANT: "Tickets.Pricing"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Publish Promoter Spring Cloud Contract to local maven repo
run: >-
cd services/Promoter &&
./gradlew publishToMavenLocal
- name: Test
run: >-
cd services/Pricing &&
./gradlew
-Dpact.verifier.publishResults=true
-Dpact.provider.version=$PACTICIPANT-${{ github.sha }}
-Dpact.provider.branchName=${{ github.ref_name }}
-Dpact.provider.tag=${{ github.ref_name }}
-Dpact.rootDir=build/pacts
test publishToMavenLocal
- name: Publish Pricing Consumer Pacts
run: >-
docker run --rm \
-w ${PWD} \
-v ${PWD}:${PWD} \
-e PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN \
pactfoundation/pact-cli:1.1.0.0 \
broker publish ${PWD}/services/Pricing/build/pacts --consumer-app-version=$PACTICIPANT-${{ github.sha }} --branch=${{github.ref_name}} --tag-with-git-branch
dev-can-i-deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Can I deploy to dev?
run: >-
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN \
pactfoundation/pact-cli:1.1.0.0 \
broker can-i-deploy --pacticipant=$PACTICIPANT --to-environment=dev --version=$PACTICIPANT-${{ github.sha }}
dev-deployment:
if: ${{ github.ref_name == 'main' }}
needs: build
runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@v4
- name: Deploy to Dev
run: echo "Deploying to dev"
- name: Record Pact deployment to dev
run: >-
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN \
pactfoundation/pact-cli:1.1.0.0 \
broker record-deployment --pacticipant=$PACTICIPANT --environment=dev --version=$PACTICIPANT-${{ github.sha }}
prod-can-i-deploy:
needs: dev-deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Can I deploy to prod?
run: >-
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN \
pactfoundation/pact-cli:1.1.0.0 \
broker can-i-deploy --pacticipant=$PACTICIPANT --to-environment=prod --version=$PACTICIPANT-${{ github.sha }} --ignore="Tickets.Promoter"
prod-deployment:
if: ${{ github.ref_name == 'main' }}
needs: dev-deployment
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v4
- name: Deploy to prod
run: echo "Deploying to prod"
- name: Record Pact deployment to prod
run: >-
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN \
pactfoundation/pact-cli:1.1.0.0 \
broker record-deployment --pacticipant=$PACTICIPANT --environment=prod --version=$PACTICIPANT-${{ github.sha }}
- name: Record Pact release to prod
run: >-
docker run --rm \
-e PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN \
pactfoundation/pact-cli:1.1.0.0 \
broker record-release --pacticipant=$PACTICIPANT --environment=prod --version=$PACTICIPANT-${{ github.sha }}