Skip to content

Commit

Permalink
[ci] send more information to the private CI
Browse files Browse the repository at this point in the history
This commit sends branch name (in case of a push) and the PR title or
the latest commit message (in case of a push) to the private CI.

The private CI and then use these information to perform batching and
display a more human friendly title in the UI.

Signed-off-by: Gary Guo <[email protected]>
  • Loading branch information
nbdd0121 authored and engdoreis committed Aug 22, 2024
1 parent d105232 commit 8b52459
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions .github/workflows/private-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Trigger Private CI
run: |
PAYLOAD='"target":"${{ github.repository_owner }}/opentitan-private-ci/master/private-ci.yml","sha":"${{ github.event.pull_request.head.sha || github.sha }}"'
if ${{ github.event_name == 'pull_request_target' }}; then
PAYLOAD+=',"pull_request":${{ github.event.pull_request.number }}'
fi
curl -fL \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"cross-repo-ci","client_payload":{'"$PAYLOAD"'}}'
- name: Trigger AscentLint CI
run: |
PAYLOAD='"target":"${{ github.repository_owner }}/opentitan-realintent-ci/main/ascentlint-ci.yml","sha":"${{ github.event.pull_request.head.sha || github.sha }}"'
if ${{ github.event_name == 'pull_request_target' }}; then
PAYLOAD+=',"pull_request":${{ github.event.pull_request.number }}'
fi
curl -fL \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"cross-repo-ci","client_payload":{'"$PAYLOAD"'}}'
uses: actions/github-script@v7
with:
script: |
const payload = {
sha: context.eventName === 'pull_request' ? context.payload.pull_request.head.sha : context.sha,
pull_request: context.issue.number,
inputs: {
// For push events, also send branch name (for batching)
branch: context.eventName === 'pull_request' ? undefined : context.ref,
run_name: context.eventName === 'pull_request' ? context.payload.pull_request.title : context.payload.head_commit.message.split('\n')[0],
},
};
await github.rest.repos.createDispatchEvent({
owner: context.repo.owner,
repo: context.repo.repo,
event_type: 'cross-repo-ci',
client_payload: {
...payload,
target: `${context.repo.owner}/opentitan-private-ci/master/private-ci.yml`,
}
});
await github.rest.repos.createDispatchEvent({
owner: context.repo.owner,
repo: context.repo.repo,
event_type: 'cross-repo-ci',
client_payload: {
...payload,
target: `${context.repo.owner}/opentitan-realintent-ci/main/ascentlint-ci.yml`,
}
});

0 comments on commit 8b52459

Please sign in to comment.