ci(label): trigger workflows on labelling #24
Workflow file for this run
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
name: Label | |
on: | |
pull_request: | |
branches: [master, vara-stage-1, vara-stage-2, vara-stage-3] | |
types: [labeled] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lbuild: | |
runs-on: ubuntu-latest | |
if: github.event.label.name == 'A0-pleasereview' || github.event.label.name == 'E2-forcemacos' | |
steps: | |
- uses: actions/github-script@v6 | |
id: label-checks | |
with: | |
script: | | |
const [owner, repo] = ["gear-tech", "gear"]; | |
// const { ref, payload: { number: issue_number } } = context; | |
const ref = "cl/issue-2888"; | |
const issue_number = 3070; | |
// List all labels of the current pull request. | |
const { data: labelsArr } = await github.rest.issues.listLabelsOnIssue({ | |
owner, | |
repo, | |
issue_number, | |
}); | |
const labels = labelsArr.map((label) => label.name); | |
let [linux, macos] = [ | |
labels.includes("A0-pleasereview"), | |
labels.includes("E2-forcemacos") | |
]; | |
if (!(linux || macos)) return; | |
// List the latest check runs | |
const { | |
data: { check_runs } | |
} = await github.rest.checks.listForRef({ | |
owner, | |
repo, | |
ref, | |
}); | |
for (run of check_runs) { | |
if (run.conclusion !== "skipped") continue; | |
if ( | |
(linux && run.name === "build") || | |
(macos && run.name === "build / macos-x86") | |
) { | |
await github.rest.checks.rerequestRun({ | |
owner, | |
repo, | |
check_run_id: run.id, | |
}); | |
} | |
} |