-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,71 @@ | ||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
env: | ||
TARGET_REPO_OWNER: 'cupy' | ||
TARGET_REPO_NAME: 'self-hosted-ci' | ||
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 = github.event.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) { | ||
// mergeable is null, wait until mergeability is determined. | ||
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 | ||
if: github.repository_owner == 'cupy' | ||
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.TARGET_REPO_OWNER }} | ||
repositories: ${{ env.TARGET_REPO_NAME }} | ||
- name: Dispach CI | ||
owner: ${{ env.CI_REPO_OWNER }} | ||
repositories: ${{ env.CI_REPO_NAME }} | ||
- name: Dispach Self-Hosted CI | ||
uses: peter-evans/repository-dispatch@v3 | ||
with: | ||
repository: ${{ env.TARGET_REPO_OWNER }}/${{ env.TARGET_REPO_NAME }} | ||
repository: ${{ env.CI_REPO_OWNER }}/${{ env.CI_REPO_NAME }} | ||
event-type: rocm-ci | ||
token: ${{ steps.generate-token.outputs.token }} | ||
client-payload: | | ||
{ | ||
"sha": "451140c6fa15d2c1bee4dda49a769563136142e8" | ||
"sha": "${{ needs.pre-dispatch.outputs.sha }}" | ||
} |