-
Notifications
You must be signed in to change notification settings - Fork 16
138 lines (118 loc) · 4.48 KB
/
ci-promoter.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
name: Promoter CI
run-name: Promoter CI
on:
push:
paths:
- 'services/Promoter/**'
- 'libs/SharedLib/**'
- '.github/workflows/ci-promoter.yml'
- '.github/workflows/ci-shared-lib.yml'
workflow_dispatch:
repository_dispatch:
types: [promoter-ci-webhook]
env:
PACT_BROKER_BASE_URL: ${{ vars.PACT_BROKER_BASE_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
PACTICIPANT: "Tickets.Promoter"
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 Pricing Spring Cloud Contract to local maven repo
run: >-
cd services/Pricing &&
./gradlew publishToMavenLocal
- name: Test
run: >-
cd services/Promoter &&
./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 Promoter 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/Promoter/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 }}
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 }}