-
Notifications
You must be signed in to change notification settings - Fork 20
46 lines (43 loc) · 1.36 KB
/
manual-pr-nda-link.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
name: "[manual]: Add NDA link"
on:
workflow_dispatch:
inputs:
prId:
description: "Pr id"
required: true
url:
description: "Url"
required: true
jobs:
nda-link:
runs-on: ubuntu-latest
steps:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "18.x"
- name: "Add link"
run: |
echo PR_ID=$PR_ID
echo URL=$URL
curl https://api.github.com/repos/ytsaurus/ytsaurus-ui/pulls/$PR_ID | jq .body | sed -E 's/<!-- nda-start -->.*<!-- nda-end -->/ /g' > body.txt
node << __EOF
const fs = require('fs')
const body = JSON.parse(fs.readFileSync('./body.txt')) || '';
fs.writeFileSync('./new-body.json', JSON.stringify({
body: [
'<!-- nda-start -->',
'$URL',
'<!-- nda-end -->' + body,
].join("\n")
}))
__EOF
curl -L -X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--data-binary @new-body.json \
https://api.github.com/repos/ytsaurus/ytsaurus-ui/pulls/$PR_ID \
env:
PR_ID: ${{ inputs.prId }}
URL: ${{ inputs.url }}