-
Notifications
You must be signed in to change notification settings - Fork 17
274 lines (253 loc) · 14.4 KB
/
devportal-update.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: Update Devportal Documentation
on:
push:
paths:
- 'README.md'
branches:
- devportalAutoImplem
permissions: read-all
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
# Step 1: Clone the Devportal Repository
- name: Clone Devportal Repository
env:
GITHUB_TOKEN: ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}
run: |
TIMESTAMP=$(date +'%Y%m%d-%H%M%S')
BRANCH_NAME="update-from-rif-relay-${TIMESTAMP}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
git clone https://github.com/rsksmart/devportal.git
cd devportal
git checkout -b ${BRANCH_NAME} || git checkout ${BRANCH_NAME}
cd ..
# Step 2: Transform Each File and Copy to Devportal Repository
- name: Transform Files for Devportal
run: |
mkdir -p transformed
# Remove the unwanted first lines from README.md
TEMP_FILE="temp_README.md"
tail -n +1 README.md > ${TEMP_FILE}
# Remove the lines between <!--START and <!--END-->
awk '/<!--START/,/<!--END-->/{next} {print}' README.md > ${TEMP_FILE}
# Process main README.md
TRANSFORMED_FILE="transformed/README.md"
echo "---" > ${TRANSFORMED_FILE}
echo "sidebar_label: Overview" >> ${TRANSFORMED_FILE}
echo "sidebar_position: 100" >> ${TRANSFORMED_FILE}
echo "title: RIF Relay - Overview" >> ${TRANSFORMED_FILE}
echo "description: 'RIF Relay Overview.'" >> ${TRANSFORMED_FILE}
echo "tags: [rif, envelope, relay, integrate, integration guide]" >> ${TRANSFORMED_FILE}
echo "---" >> ${TRANSFORMED_FILE}
echo "" >> ${TRANSFORMED_FILE}
echo ":::info[Note]" >> ${TRANSFORMED_FILE}
echo "If you wish to suggest changes on this document, please open a PR on the [Rif Relay Repository](https://github.com/rsksmart/rif-relay.git)" >> ${TRANSFORMED_FILE}
echo ":::" >> ${TRANSFORMED_FILE}
echo "" >> ${TRANSFORMED_FILE}
cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# Clean up temporary file
rm ${TEMP_FILE}
cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/overview.md
# Process integrations section
TEMP_FILE="temp_integrate.md"
TRANSFORMED_FILE="transformed/integrate.md"
echo "new temp file name is"
echo ${TEMP_FILE}
echo "new transformed file name is"
echo ${TRANSFORMED_FILE}
# Remove the unwanted first lines from section (title)
tail -n +1 docs/integrate.md > ${TEMP_FILE}
echo "---" > ${TRANSFORMED_FILE}
echo "sidebar_label: Integrations" >> ${TRANSFORMED_FILE}
echo "sidebar_position: 200" >> ${TRANSFORMED_FILE}
echo "title: RIF Relay Integration >> ${TRANSFORMED_FILE}
echo "description: 'Integrating RIF Relay in a dApp.'" >> ${TRANSFORMED_FILE}
echo "tags: [rif, envelope, relay, integration guide]" >> ${TRANSFORMED_FILE}
echo "---" >> ${TRANSFORMED_FILE}
echo "" >> ${TRANSFORMED_FILE}
cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# Clean up temporary file
rm ${TEMP_FILE}
cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/integrate.md
# # Process setup section
# TEMP_FILE="temp_installation-requirements.md"
# TRANSFORMED_FILE="transformed/installation-requirements.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/installation-requirements.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Setup" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 300" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay Installation Requirements >> ${TRANSFORMED_FILE}
# echo "description: 'Requirements for installing RIF Relay.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, user, guide]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/installation-requirements.md
# # Process sample dapp section
# TEMP_FILE="temp_sample-dapp.md"
# TRANSFORMED_FILE="transformed/sample-dapp.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/sample-dapp.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: RIF Relay Sample dApp" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 400" >> ${TRANSFORMED_FILE}
# echo "title: How to use the RIF Relay Sample dApp SDK >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay Sample dApp SDK Starter kit.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, integration guide]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/sample-dapp.md
# # Process deployment section
# TEMP_FILE="temp_deployment.md"
# TRANSFORMED_FILE="transformed/deployment.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/deployment.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: RIF Relay Deployment" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 500" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay Deployment >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay deployment process.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, integration guide]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/deployment.md
# # Process develop section
# TEMP_FILE="temp_develop.md"
# TRANSFORMED_FILE="transformed/develop.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/develop.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Develop" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 600" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay Develop >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay deployment process.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, user, guide]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/develop.md
# # Process contracts section
# TEMP_FILE="temp_contracts.md"
# TRANSFORMED_FILE="transformed/contracts.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/contracts.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Contracts" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 700" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay - Contracts >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay Contracts.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, integrate]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/contracts.md
# # Process smart wallets section
# TEMP_FILE="temp_smart-wallets.md"
# TRANSFORMED_FILE="transformed/smart-wallets.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/smart-wallets.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Smart Wallets" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 800" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay Smart Wallets >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay Smart Wallets.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, user, guide]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/smart-wallets.md
# # Process versions section
# TEMP_FILE="temp_versions.md"
# TRANSFORMED_FILE="transformed/versions.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/versions.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Versions" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 900" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay Versions >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay Versions.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, rif relay, integration guide]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/versions.md
# # Process gas costs section
# TEMP_FILE="temp_gas-costs.md"
# TRANSFORMED_FILE="transformed/gas-costs.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/gas-costs.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Gas Costs" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 950" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay - Gas Costs >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay Gas Costs.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, integrate]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/gas-costs.md
# # Process architecture section
# TEMP_FILE="temp_architecture.md"
# TRANSFORMED_FILE="transformed/architecture.md"
# # Remove the unwanted first lines from section (title)
# tail -n +1 docs/architecture.md > ${TEMP_FILE}
# echo "---" > ${TRANSFORMED_FILE}
# echo "sidebar_label: Architecture" >> ${TRANSFORMED_FILE}
# echo "sidebar_position: 980" >> ${TRANSFORMED_FILE}
# echo "title: RIF Relay - Architecture >> ${TRANSFORMED_FILE}
# echo "description: 'RIF Relay Architeture.'" >> ${TRANSFORMED_FILE}
# echo "tags: [rif, envelope, relay, integrate]" >> ${TRANSFORMED_FILE}
# echo "---" >> ${TRANSFORMED_FILE}
# echo "" >> ${TRANSFORMED_FILE}
# cat ${TEMP_FILE} >> ${TRANSFORMED_FILE}
# # Clean up temporary file
# rm ${TEMP_FILE}
# cp ${TRANSFORMED_FILE} devportal/docs/02-developers/06-integrate/01-rif-relay/architecture.md
# Step 3: Commit and Push Changes to Devportal Repository
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}
run: |
cd devportal
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/02-developers/06-integrate/01-rif-relay/overview.md
git add docs/02-developers/06-integrate/01-rif-relay/integrate.md
# git add docs/02-developers/06-integrate/01-rif-relay/overview.md docs/02-developers/06-integrate/01-rif-relay/integrate.md docs/02-developers/06-integrate/01-rif-relay/installation-requirements.md docs/02-developers/06-integrate/01-rif-relay/sample-dapp.md docs/02-developers/06-integrate/01-rif-relay/deployment.md docs/02-developers/06-integrate/01-rif-relay/develop.md docs/02-developers/06-integrate/01-rif-relay/contracts.md docs/02-developers/06-integrate/01-rif-relay/smart-wallets.md docs/02-developers/06-integrate/01-rif-relay/versions.md docs/02-developers/06-integrate/01-rif-relay/gas-costs.md docs/02-developers/06-integrate/01-rif-relay/architecture.md
git commit -m "Automated update from repository"
# Configure the remote URL with the token for authentication
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/rsksmart/devportal.git
git push -f origin ${BRANCH_NAME}
# Step 4: Create a Pull Request in the Devportal Repository
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}
run: |
cd devportal
curl -L -X POST -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.DEVPORTAL_DOCS_UPDATE_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/rsksmart/devportal/pulls \
-d "{\"title\":\"Rif-relay automated update of documentation ${BRANCH_NAME}\",\"body\":\"This PR updates the Devportal documentation with the latest changes from the original repository.\",\"head\":\"${BRANCH_NAME}\",\"base\":\"main\"}"