-
Notifications
You must be signed in to change notification settings - Fork 51
158 lines (145 loc) · 5.64 KB
/
on_pr_opened.yaml
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
name: Install/upgrade PR Instance
on:
pull_request:
branches:
- main
paths:
- "plugins/**"
- "services/tenant-ui/**"
- "charts/traction/**"
- "charts/tenant-ui/**"
types:
- opened
- synchronize
- reopened
- ready_for_review
jobs:
ready:
name: "Install if ready for review"
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.ready_for_review.outputs.true_false }}
build: ${{ steps.ready_for_review.outputs.bcgov_true_false }}
steps:
- id: ready_for_review
run: |
echo "true_false=${{ toJSON(github.event.pull_request.draft != true && github.repository_owner == 'bcgov') }}" >> $GITHUB_OUTPUT
echo "bcgov_true_false=${{ toJSON(github.repository_owner == 'bcgov') }}" >> $GITHUB_OUTPUT
build_ui:
name: "Build Tenant UI"
runs-on: ubuntu-latest
if: ${{ always() && fromJSON(needs.ready.outputs.build) == true }}
needs:
- ready
steps:
- uses: actions/checkout@v3
- name: Build UI
uses: ./.github/actions/build_ui
id: builder
with:
context: "./services/tenant-ui"
image_name: ${{ github.repository_owner}}/traction-tenant-ui
registry: ghcr.io
registry_username: ${{ github.repository_owner}}
registry_password: ${{ secrets.GITHUB_TOKEN }}
outputs:
image_tag: ${{ steps.builder.outputs.image_tag }}
image_version: ${{ steps.builder.outputs.image_version }}
buildtime: ${{ steps.builder.outputs.buildtime }}
build_acapy:
name: "Build Traction Aca-Py"
runs-on: ubuntu-latest
if: ${{ always() && fromJSON(needs.ready.outputs.build) == true }}
needs:
- ready
steps:
- uses: actions/checkout@v3
- name: Build Aca-Py Image
uses: ./.github/actions/build_acapy
id: builder
with:
context: "./plugins"
dockerfile: "./plugins/docker/Dockerfile"
image_name: ${{ github.repository_owner}}/traction-plugins-acapy
registry: ghcr.io
registry_username: ${{ github.repository_owner}}
registry_password: ${{ secrets.GITHUB_TOKEN }}
outputs:
image_tag: ${{ steps.builder.outputs.image_tag }}
build_proxy:
name: "Build Traction Tenant Proxy"
runs-on: ubuntu-latest
if: ${{ always() && fromJSON(needs.ready.outputs.build) == true }}
needs:
- ready
steps:
- uses: actions/checkout@v3
- name: Build Tenant Proxy Image
uses: ./.github/actions/build_acapy
id: builder
with:
context: "./plugins"
dockerfile: "./plugins/docker/Dockerfile.tenant-proxy"
image_name: ${{ github.repository_owner}}/traction-tenant-proxy
registry: ghcr.io
registry_username: ${{ github.repository_owner}}
registry_password: ${{ secrets.GITHUB_TOKEN }}
outputs:
image_tag: ${{ steps.builder.outputs.image_tag }}
deploy:
name: Deploy PR
environment: development
runs-on: ubuntu-latest
needs:
- ready
- build_ui
- build_acapy
- build_proxy
if: ${{ always() && (fromJSON(needs.ready.outputs.deploy) == true) && !(contains(needs.*.result, 'failure')) }}
steps:
- uses: actions/checkout@v3
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
certificate_authority_data: ${{ secrets.OPENSHIFT_CA_CRT }}
namespace: ${{ secrets.OPENSHIFT_NAMESPACE }}
- name: Run Traction PR Helm
run: |
helm upgrade --install pr-${{ github.event.number }}-traction -f ./deploy/traction/values-pr.yaml --set acapy.image.tag=pr-${{ github.event.number }} --set traction_proxy.image.tag=pr-${{ github.event.number }} --set ui.image.tag=pr-${{ github.event.number }} ./charts/traction --wait
- name: Restart Traction PR Pods
run: |
oc rollout restart deployment/pr-${{ github.event.number }}-traction-acapy
oc rollout restart deployment/pr-${{ github.event.number }}-traction-tenant-proxy
oc rollout restart deployment/pr-${{ github.event.number }}-traction-tenant-ui
deploymenturls:
name: Deployment URLs comment
runs-on: ubuntu-latest
needs:
- deploy
if: ${{ (fromJSON(needs.ready.outputs.deploy) == true) && !(contains(needs.*.result, 'failure')) }}
steps:
- uses: actions/checkout@v3
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.number }}
comment-author: "github-actions[bot]"
body-includes: Deployment URLs ready for review.
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.number }}
body: |
| Deployment | Resource | Location |
| --- | --- | --- |
| Traction | |
| | Tenant UI | https://pr-${{ github.event.number }}-traction-tenant-ui-dev.apps.silver.devops.gov.bc.ca |
| | Innkeeper UI | https://pr-${{ github.event.number }}-traction-tenant-ui-dev.apps.silver.devops.gov.bc.ca/innkeeper |
| Aca-Py | | |
| | Admin Swagger | https://pr-${{ github.event.number }}-traction-acapy-admin-dev.apps.silver.devops.gov.bc.ca/api/doc |
| | Tenant Proxy Swagger | https://pr-${{ github.event.number }}-traction-tenant-proxy-dev.apps.silver.devops.gov.bc.ca/api/doc |
Deployment URLs ready for review.