-
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (67 loc) · 2.26 KB
/
dispatch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 }}"
}