Skip to content

Commit

Permalink
ci(label): conditional dispatching build
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Aug 16, 2023
1 parent 75c3af9 commit d9c2ddc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:

jobs:
linux:
if: ${{ always() && inputs.linux }}
if: ${{ inputs.linux }}
runs-on: [kuberunner, github-runner-02]
env:
LLVM_PROFILE_FILE: "gear-%p-%m.profraw"
Expand Down
46 changes: 29 additions & 17 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,54 @@ concurrency:
cancel-in-progress: true

jobs:
build:
# uses: ./.github/workflows/build.yml
# # TODO: dispatch this workflow with github action API
# # for more conditions. for example, if the there is
# # already a build check exist. (issue-2888)
# if: github.event.label.name == 'A0-pleasereview'
# with:
# macos: ${{ github.event.label.name == 'E2-forcemacos' }}
check:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: label-checks
with:
script: |
const [owner, repo] = ["gear-tech", "gear"];
const { ref, payload: { issue } } = context;
// const ref = "cl/issue-2888";
// const issue_number = 3070;
const { ref, payload: { issue: issue_number } } = context;
// List all labels of the current pull request.
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
const { data: labelsArr } = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number,
});
console.log(labels);
const labels = labelsArr.map((label) => label.name);
let [linux, macos] = [
labels.includes("A0-pleasereview"),
labels.includes("E2-forcemacos")
];
if (linux == macos == false) return;
// List the latest check runs
const {
data: {
check_runs
}
data: { check_runs }
} = await github.rest.checks.listForRef({
owner,
repo,
ref,
});
// console.log(check_runs);
for (const run in check_runs) {
if (run.name == "build) {
linux = (run.conclusion == "skipped");
} else if (run.name == "build / macos") {
macos = (run.conclusion == "skipped");
}
}
const build = linux || macos;
return { build, linux, win: linux, macos }
- uses: ./.github/workflows/build.yml
if: ${{ steps.label-checks.outputs.result.build }}
with:
linux: ${{ steps.label-checks.outputs.result.linux }}
win: ${{ steps.label-checks.outputs.result.win }}
macos: ${{ steps.label-checks.outputs.result.macos }}

0 comments on commit d9c2ddc

Please sign in to comment.