-
Notifications
You must be signed in to change notification settings - Fork 191
88 lines (75 loc) · 3.22 KB
/
validate_new_address_issue_input_data.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
name: "Validate the add address issue inputs"
on:
issues:
types: [opened, edited]
jobs:
validate-issue-inputs:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'add-new-address')
steps:
- name: Get issue inputs
id: get-issue-inputs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueBody = context.payload.issue.body.replaceAll("_No response_", "");
const titles = {
summary: 'Summary',
chainId: 'Chain ID',
chainDetailUrl: 'Chain detail URL',
rpcUrl: 'RPC URL',
blockscoutClientUrl: 'Blockscout Client URL',
etherscanClientUrl: 'Etherscan Client URL',
etherscanClientApiUrl: 'Etherscan Client API URL',
version: 'Version',
addressMasterCopy: 'Address \\(Master copy\\)',
txHashMasterCopy: 'Deployment Tx hash \\(Master copy\\)',
blockExplorerUrlMasterCopy: 'Block explorer URL \\(Master copy\\)',
addressMasterCopyL2: 'Address \\(Master copy L2\\)',
txHashMasterCopyL2: 'Deployment Tx hash \\(Master copy L2\\)',
blockExplorerUrlMasterCopyL2: 'Block explorer URL \\(Master copy L2\\)',
addressProxy: 'Address \\(Proxy factory\\)',
txHashProxy: 'Deployment Tx hash \\(Proxy factory\\)',
blockExplorerUrlProxy: 'Block explorer URL \\(Proxy factory\\)',
};
const buildPattern = title => new RegExp(`### ${title}(?:\\r\\n\\r\\n|\\n\\n|\\n|\\r\\n)(.+?)(?:\\r\\n\\r\\n|\\n\\n|\\n|\\r\\n)`);
const extractInfo = (pattern, text) => {
const match = text.match(pattern);
return match ? match[1].trim() : null;
};
const extractedInfo = {};
Object.keys(titles).forEach(key => {
const pattern = buildPattern(titles[key]);
extractedInfo[key] = extractInfo(pattern, issueBody);
});
console.log('Extracted Info:', extractedInfo);
return extractedInfo;
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
grep -E "web3" requirements.txt | xargs pip install safe-eth-py@git+https://github.com/safe-global/safe-eth-py@main validators tldextract
- name: Validate input data
id: validate-input-data
env:
ISSUE_BODY_INFO: ${{ steps.get-issue-inputs.outputs.result }}
run: |
python .github/scripts/github_adding_addresses/validate_new_address_issue_input_data.py
- name: Add comment to issue
uses: actions/github-script@v7
env:
COMMENT_OUTPUT: ${{ steps.validate-input-data.outputs.comment_message }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.COMMENT_OUTPUT
})