-
Notifications
You must be signed in to change notification settings - Fork 9
209 lines (162 loc) · 8.51 KB
/
instance-configuration-validation-bot.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Instance Configuration Validation Bot
on:
issues:
types:
- opened
- edited
jobs:
validate-form:
if: ${{ contains(github.event.issue.labels.*.name, 'new instance') }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
#########################################################################
# Initial Hello and Documentation
- name: Find Validation Results Comment - Pre Run
uses: peter-evans/find-comment@v2
id: find-validation-results-comment-pre
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Form Validation Results'
- name: Set Initial Comment State
uses: peter-evans/create-or-update-comment@v3
if: ${{ steps.find-validation-results-comment-pre.outputs.comment-id == 0 }}
with:
issue-number: ${{ github.event.issue.number }}
body: |
Hello! 👋
Thanks for initiating the process to configure a new CDP instance.
I am a bot that will validate the information provided in your form. If any check fails, please update your issue by opening the '⋯' dropdown in the top-right-corner of your GitHub Issue and selecting 'Edit'. I will automatically rerun the checks after you update the issue to validate the changes.
A member from the CDP team will respond as soon as possible!
#### Form Validation Results
:hourglass_flowing_sand: Validating planned instance maintainer
:hourglass_flowing_sand: Validating planned instance repository name
:hourglass_flowing_sand: Determining event scraper strategy and optionally testing Legistar
#### All Cookiecutter Parameters
:hourglass_flowing_sand: Generating...
_This comment was written by a bot!_
- name: Reset Initial Comment State
uses: peter-evans/create-or-update-comment@v3
if: ${{ steps.find-validation-results-comment-pre.outputs.comment-id != 0 }}
with:
comment-id: ${{ steps.find-validation-results-comment-pre.outputs.comment-id }}
edit-mode: 'replace'
body: |
Hello! 👋
Thanks for initiating the process to configure a new CDP instance.
I am a bot that will validate the information provided in your form. If any check fails, please update your issue by opening the '⋯' dropdown in the top-right-corner of your GitHub Issue and selecting 'Edit'. I will automatically rerun the checks after you update the issue to validate the changes.
A member from the CDP team will respond as soon as possible!
#### Form Validation Results
:hourglass_flowing_sand: Validating planned instance maintainer
:hourglass_flowing_sand: Validating planned instance repository name
:hourglass_flowing_sand: Determining event scraper strategy and optionally testing Legistar
#### All Cookiecutter Parameters
:hourglass_flowing_sand: Generating...
_This comment was written by a bot!_
#########################################################################
# Workflow Setup
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Bot Scripts Dependencies
run: |
pip install --upgrade pip
pip install -r .github/workflows/scripts/requirements.txt
#########################################################################
# Parsing Form and Logging Details
- name: Dump Issue Body to File
run: |
echo "${{ github.event.issue.body }}" > issue-body.md
- name: Validate Form and Create Bot Response
run: |
python .github/workflows/scripts/validate_form.py issue-body.md
- name: Set Response Content
id: validation-message-response
run: |
body=$(cat form-validation-results.md)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::"$body"
- name: Dump Cookiecutter Parameters
id: dump-cookiecutter-parameters
run: |
set -f
body=$(cat planned-cookiecutter.json)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Get Infrastructure Metadata
id: infra-meta
run: |
slug=$(jq -r '.municipality_slug' planned-cookiecutter.json)
infra_slug=$(jq -r '.infrastructure_slug' planned-cookiecutter.json)
region=$(jq -r '.firestore_region' planned-cookiecutter.json)
echo "::set-output name=slug::$slug"
echo "::set-output name=infra_slug::$infra_slug"
echo "::set-output name=region::$region"
- name: Find Validation Results Comment - Post Run
uses: peter-evans/find-comment@v2
id: find-validation-results-comment-post
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Form Validation Results'
- name: Post Validation Results
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-validation-results-comment-post.outputs.comment-id }}
edit-mode: 'replace'
body: |
Hello! 👋
Thanks for initiating the process to configure a new CDP instance.
I am a bot that will validate the information provided in your form. If any check fails, please update your issue by opening the '⋯' dropdown in the top-right-corner of your GitHub Issue and selecting 'Edit'. I will automatically rerun the checks after you update the issue to validate the changes.
A member from the CDP team will respond as soon as possible!
#### Form Validation Results
${{ steps.validation-message-response.outputs.body }}
#### All Cookiecutter Parameters
```json
${{ steps.dump-cookiecutter-parameters.outputs.body }}
```
---
#### Steps for Internal CDP Team
To proceed with the deployment process, please do the following:
* [ ] Run `get_cdp_infrastructure_stack dev-infrastructure/`
* [ ] Run `just login` in cdp-backend/dev-infrastructure and login to the CDP gcloud account
* [ ] Run `just init ${{ steps.infra-meta.outputs.infra_slug }}` in cdp-backend/dev-infrastructure
* [ ] Run `just setup ${{ steps.infra-meta.outputs.infra_slug }} ${{ steps.infra-meta.outputs.region }}` in cdp-backend/dev-infrastructure
* [ ] Setup Firebase Storage [Link](https://console.firebase.google.com/u/0/project/${{ steps.infra-meta.outputs.infra_slug }}/storage)
* [ ] Comment "/cdp-deploy" on this issue and follow the rest of the instructions
More details on the `just` commands can be found in [cdp-backend](https://github.com/CouncilDataProject/cdp-backend/tree/main/dev-infrastructure).
_This comment was written by a bot!_
- name: Find Infrastructure Slug Comment
uses: peter-evans/find-comment@v2
id: find-infra-slug-comment
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Generated Infrastructure Slug'
- name: Set Initial Infra Slug Comment State
uses: peter-evans/create-or-update-comment@v3
if: ${{ steps.find-infra-slug-comment.outputs.comment-id == 0 }}
with:
issue-number: ${{ github.event.issue.number }}
body: |
##### Generated Infrastructure Slug
`${{ steps.infra-meta.outputs.infra_slug }}`
_This comment was written by a bot!_
- name: Reset Infra Slug Comment State
uses: peter-evans/create-or-update-comment@v3
if: ${{ steps.find-infra-slug-comment.outputs.comment-id != 0 }}
with:
comment-id: ${{ steps.find-infra-slug-comment.outputs.comment-id }}
edit-mode: 'replace'
body: |
##### Generated Infrastructure Slug
`${{ steps.infra-meta.outputs.infra_slug }}`
_This comment was written by a bot!_