From cbc78f69a52190df9949881b61fa3ef9569bffae Mon Sep 17 00:00:00 2001 From: Tiziano Santoro Date: Thu, 23 Apr 2020 11:20:44 +0100 Subject: [PATCH] Fix posting reproducibility index to PR The current version does not work because when running on merge events the PR number is not present, so we need to look it up based on commit SHA. Ref #861 --- .github/workflows/reproducibility.yaml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reproducibility.yaml b/.github/workflows/reproducibility.yaml index 7d265379595..4ab03ed9f55 100644 --- a/.github/workflows/reproducibility.yaml +++ b/.github/workflows/reproducibility.yaml @@ -44,11 +44,25 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} script: | const fs = require('fs').promises; - file_content = await fs.readFile('./reproducibility_index'); + const file_content = await fs.readFile('./reproducibility_index'); + + const opts = await github.repos.listPullRequestsAssociatedWithCommit({ + owner: context.repo.owner, + repo: context.repo.repo, + commit_sha: context.sha + }); + // See: + // - https://octokit.github.io/rest.js/v17#previews + // - https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-commit + opts.mediaType = { + previews: ['groot'] + }; + + const issues = await github.paginate(opts); await github.issues.createComment({ - issue_number: context.issue.number, + issue_number: issues[0].number, owner: context.repo.owner, repo: context.repo.repo, body: 'Reproducibility index:\n\n```\n' + file_content + '\n```\n' - }) + });