-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (65 loc) · 2.8 KB
/
run-latest-proposal.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
name: "Run Latest Proposal"
env:
FOUNDRY_PROFILE: "ci"
ARB_RPC_URL: ${{secrets.ARB_RPC_URL}}
on: [pull_request]
jobs:
run-proposal:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"
- name: Get Changed Files
id: files
uses: jitterbit/get-changed-files@v1
with:
format: "space-delimited"
- name: Set PR_CHANGED_FILES
run: echo "PR_CHANGED_FILES=${{ steps.files.outputs.all }}" >> $GITHUB_ENV
- name: Set DEBUG flag
run: echo "DEBUG=true" >> $GITHUB_ENV
- name: Set PROPOSALS_FOLDER
run: echo "PROPOSALS_FOLDER=src/proposals" >> $GITHUB_ENV
- name: List and Delete Previous Comments
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = context.payload.pull_request.number;
const comments = await github.rest.issues.listComments({
...context.repo,
issue_number: issue_number
});
const actionComments = comments.data.filter(comment => comment.user.login === 'github-actions[bot]');
if (actionComments.length === 0) {
return;
}
for (const comment of actionComments) {
await github.rest.issues.deleteComment({
...context.repo,
comment_id: comment.id,
});
}
- name: Run Proposal
run: ./run-proposal.sh
- name: Comment PR with Proposal Output
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
if (fs.existsSync('output.json')) {
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
const prNumber = context.payload.pull_request.number;
github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: `### Proposal output for ${output.file}:\n\`\`\`\n${output.output}\n\`\`\``
});
}