Skip to content

Commit

Permalink
try to comment on PR from forks
Browse files Browse the repository at this point in the history
  • Loading branch information
lldelisle committed Jan 11, 2024
1 parent a0775d2 commit 5f19ae1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/comment_on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Comment on the pull request

# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["Galaxy Workflow Tests for push and PR"]
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request'
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 == 'All tool test results'
})[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}}/upload.zip', Buffer.from(download.data));
- run: unzip upload.zip
- name: Check the output of unzip
run: |
ls
- name: 'Comment on PR'
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
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('./tool_test_output.md')
});
22 changes: 5 additions & 17 deletions .github/workflows/workflow_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ jobs:
html-report: true
markdown-report: true
- run: cat upload/tool_test_output.md >> $GITHUB_STEP_SUMMARY
- name: Save PR number
run: echo ${{ github.event.number }} > ./upload/NR
- name: Debug PR number
run: |
cat ./upload/NR
- uses: actions/upload-artifact@v3
with:
name: 'All tool test results'
Expand All @@ -98,23 +103,6 @@ jobs:
id: check
with:
mode: check
- name: Get PR object
if: failure()
uses: 8BitJonny/[email protected]
id: failed_pr_number
with:
sha: ${{ github.event.pull_request.head.sha }}
- name: Debug GetPR output
if: failure()
run: |
echo ${{ steps.failed_pr_number.outputs.number }}
- name: Post comment with test report
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
issue-number: ${{ steps.failed_pr_number.outputs.number }}
body-path: upload/tool_test_output.md

# deploy workflows to organization
deploy:
Expand Down

0 comments on commit 5f19ae1

Please sign in to comment.