Skip to content

add state diff proposal example #46

add state diff proposal example

add state diff proposal example #46

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\`\`\``
});
}