Comment on the pull request #296
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment on the pull request | |
# read-write repo token | |
# access to secrets | |
on: | |
workflow_run: | |
workflows: ["Receive PR"] | |
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/github-script@v3.1.0 | |
with: | |
script: | | |
let artifacts = await github.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id }}, | |
}); | |
let matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "pr" | |
})[0]; | |
let download = await github.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let 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@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var lines = require('fs').readFileSync('./NR', 'utf-8') | |
.split('\n') | |
.filter(Boolean); | |
console.log(lines); | |
var issue_number = Number(lines[0]); | |
var dataset_list = lines[1]; | |
console.log(issue_number); | |
console.log(dataset_list); | |
var comment = 'This is an automatic reminder for pasting the local test results of `'; | |
comment += dataset_list; | |
comment += '` as a comment in this PR, in case you haven\'t done so. The aforementioned datasets are too large for them to be tested with GitHub Action workflow here.\n The local test result for each dataset can be obtained by running `make pytest DATASET=<dataset name>`. For more details, please refer to [the dataset submission guide](https://github.com/Graph-Learning-Benchmarks/gli/blob/main/CONTRIBUTING.md#contributing-a-new-dataset).'; | |
if (lines.length > 1){ | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: comment | |
}); | |
} |