Skip to content

Commit

Permalink
ci: add workflow for pr comment
Browse files Browse the repository at this point in the history
Signed-off-by: smrpn <[email protected]>
  • Loading branch information
0xethsign committed Apr 21, 2021
1 parent 97d71e3 commit 1c79d5b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/commentPR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Comment on the pull request

# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["Benchmarks"]
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Download artifact'
uses: actions/[email protected]
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip

- name: 'Comment on PR'
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var file = "benchResults.txt"
if (file) {
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: (fs.readFileSync('./benchResults.txt')).toString('utf8')
});
}

10 changes: 10 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ jobs:
with:
cwd: benches
token: ${{ secrets.GITHUB_TOKEN }}


- name: Save PR number
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- uses: actions/upload-artifact@v2
with:
name: pr
path: pr/

0 comments on commit 1c79d5b

Please sign in to comment.