-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (160 loc) · 5.91 KB
/
ConsumerCI.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: ConsumerCI
on:
workflow_dispatch:
inputs:
application_name:
description: name of consumer
required: true
default: 'SmartBearCoin-Payments-UI'
provider_name:
description: name of provider
required: true
default: 'SmartBearCoin-Payee-Provider'
demo_deploy:
description: skip deployment steps for demo
required: true
default: 'false'
push:
paths:
- 'smartbearcoin-payments-ui/**'
- '.github/workflows/ConsumerCI.yml'
- 'oas/**'
pull_request:
branches: ['main']
paths:
- 'smartbearcoin-payments-ui/**'
- '.github/workflows/ConsumerCI.yml'
- 'oas/**'
env:
version: ${{ github.sha }}
application_folder: smartbearcoin-payments-ui
jobs:
setup:
name: 🏗️ setup
runs-on: ubuntu-latest
steps:
- run: echo "application_name=${application_name:-${application_name_default}}" >> $GITHUB_ENV
- run: echo "provider_name=${provider_name:-${provider_name_default}}" >> $GITHUB_ENV
env:
application_name: ${{ github.event.inputs.application_name }}
application_name_default: SmartBearCoin-Payments-UI
provider_name: ${{ github.event.inputs.provider_name }}
provider_name_default: SmartBearCoin-Payee-Provider
outputs:
PACT_CONSUMER: ${{ env.application_name }}
PACT_PROVIDER: ${{ env.provider_name }}
test:
needs: setup
runs-on: ubuntu-latest
env:
PACT_CONSUMER: ${{ needs.setup.outputs.PACT_CONSUMER }}
PACT_PROVIDER: ${{ needs.setup.outputs.PACT_PROVIDER }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: cd ${{ env.application_folder }} && npm ci
- run: cd ${{ env.application_folder }} && npm test
- uses: pactflow/actions/publish-pact-files@v2
with:
broker_url: https://smartbear.pactflow.io
token: ${{ secrets.PACT_BROKER_TOKEN }}
pactfiles: ${{ env.application_folder }}/pacts
can-i-deploy-to-acc:
needs: [setup, test]
runs-on: ubuntu-latest
env:
deploy_target: acceptance
steps:
- name: can-i-deploy ${{ needs.setup.outputs.PACT_CONSUMER }} to ${{ env.deploy_target }}
uses: pactflow/actions/can-i-deploy@v2
with:
broker_url: https://smartbear.pactflow.io
token: ${{ secrets.PACT_BROKER_TOKEN }}
to_environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}
can-i-deploy-to-production:
needs: [setup, test]
runs-on: ubuntu-latest
env:
deploy_target: production
steps:
- name: can-i-deploy ${{ needs.setup.outputs.PACT_CONSUMER }} to ${{ env.deploy_target }}
uses: pactflow/actions/can-i-deploy@v2
with:
broker_url: https://smartbear.pactflow.io
token: ${{ secrets.PACT_BROKER_TOKEN }}
to_environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}
deploy-to-acc:
if: github.ref == 'refs/heads/main'
needs: [setup, can-i-deploy-to-acc]
runs-on: ubuntu-latest
env:
deploy_target: acceptance
REACT_APP_API_BASE_URL: https://sbdevrel-fua-smartbearcoin-acc.azurewebsites.net/api
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Build site
run: |
cd ${{ env.application_folder }}
npm ci
npm run build
- name: Deploy website to ${{ env.deploy_target }} environment
uses: nwtgck/[email protected]
with:
publish-dir: './${{ env.application_folder }}/build'
alias: ${{ env.deploy_target }}
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'Deploy from GitHub Actions'
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: record-deployment ${{ needs.setup.outputs.PACT_CONSUMER }} to ${{ env.deploy_target }}
uses: pactflow/actions/record-deployment@v2
with:
broker_url: https://smartbear.pactflow.io
token: ${{ secrets.PACT_BROKER_TOKEN }}
environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}
deploy-to-production:
if: github.ref == 'refs/heads/main'
needs: [setup, can-i-deploy-to-production, deploy-to-acc]
runs-on: ubuntu-latest
env:
deploy_target: production
REACT_APP_API_BASE_URL: https://sbdevrel-fua-smartbearcoin-prd.azurewebsites.net/api
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Build site
run: |
cd ${{ env.application_folder }}
npm ci
npm run build
- name: Deploy website to ${{ env.deploy_target }} environment
uses: nwtgck/[email protected]
with:
publish-dir: './${{ env.application_folder }}/build'
production-branch: main
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'Deploy from GitHub Actions'
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: record-deployment ${{ needs.setup.outputs.PACT_CONSUMER }} to ${{ env.deploy_target }}
uses: pactflow/actions/record-deployment@v2
with:
broker_url: https://smartbear.pactflow.io
token: ${{ secrets.PACT_BROKER_TOKEN }}
environment: ${{ env.deploy_target }}
application_name: ${{ needs.setup.outputs.PACT_CONSUMER }}