Skip to content

Test PR

Test PR #14

Workflow file for this run

on:
issue_comment:
types: [created]
env:
CI_REPO_OWNER: 'cupy'
CI_REPO_NAME: 'self-hosted-ci'
jobs:
pre-dispatch:
if: github.repository_owner == 'cupy'
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.pull-request.outputs.sha }}
steps:
# TODO Support workflow_dispatch and push.
- name: 'Handle Pull Request Comments'
id: pull-request
if: github.event_name == 'issue_comment' && github.event.issue.pull_request
uses: actions/github-script@v7
with:
script: |
// Check if the comment contain "/test rocm" request.
const comments = context.payload.comment.body.split('\n');
if (!lines.some(line => line.trim().startsWith('/test ') && line.includes('rocm'))) {
return;
}
// Get the merge commit SHA.
for (let i = 0; i < 10; i++) {
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const mergeable = pr.data.mergeable;
if (mergeable === null) {
console.log('Waiting for GitHub to determine mergeability...');
await new Promise(r => setTimeout(r, 1000));
continue;
}
if (mergeable === true) {
core.setOutput('sha', pr.data.merge_commit_sha);
} else {
core.setFailed('The pull request is not mergeable.');
}
break;
}
dispatch:
needs: pre-dispatch
runs-on: ubuntu-latest
steps:
- name: Generate Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.GH_APP_SELF_HOSTED_CI_ID }}
private-key: ${{ secrets.GH_APP_SELF_HOSTED_CI_PEM }}
owner: ${{ env.CI_REPO_OWNER }}
repositories: ${{ env.CI_REPO_NAME }}
- name: Dispach Self-Hosted CI
uses: peter-evans/repository-dispatch@v3
with:
repository: ${{ env.CI_REPO_OWNER }}/${{ env.CI_REPO_NAME }}
event-type: rocm-ci
token: ${{ steps.generate-token.outputs.token }}
client-payload: |
{
"sha": "${{ needs.pre-dispatch.outputs.sha }}"
}