-
Notifications
You must be signed in to change notification settings - Fork 553
74 lines (66 loc) · 2.36 KB
/
private-ci.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
72
73
74
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: Ibex Private CI
on:
push:
tags:
- "*"
merge_group:
types:
- checks_requested
pull_request_target:
branches:
- "*"
permissions:
statuses: write
jobs:
trigger:
name: Trigger Private CI
runs-on: ubuntu-latest
steps:
# Find a merge commit. We cannot use merge_commit_sha from context directly because
# mergeability check is asynchronous to pull_request_target trigger..
- name: Find the merge commit
id: merge
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
for (let i = 0; i <= 5; i++) {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
if (i != 5 && pr.mergeable == null) {
console.log("Mergeability check in progress");
await new Promise(r => setTimeout(r, 2000));
continue;
}
if (pr.mergeable) {
core.setOutput('merge_sha', pr.merge_commit_sha);
} else {
core.setFailed('Pull request is not mergeable');
}
break;
}
# Create pending statuses to block merge group and give indication before jobs are picked up.
- name: Create pending statuses
run: |
gh api --method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha || github.sha }} \
-f state='pending' \
-f context='Ibex Private CI' \
-f description='Queued'
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Trigger Private CI
run: |
gh workflow run ibex-private-ci.yml --repo lowRISC/lowrisc-private-ci \
-f ref="${{ github.event.pull_request.head.sha || github.sha }}" \
-f sha="${{ steps.merge.outputs.merge_sha || github.sha }}"
env:
GITHUB_TOKEN: ${{ secrets.LOWRISC_PRIVATE_CI_PAT }}