Skip to content

Commit

Permalink
ci(label): share outputs between steps
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Aug 16, 2023
1 parent d9c2ddc commit cfb9722
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ concurrency:
cancel-in-progress: true

jobs:
check:
status:
runs-on: ubuntu-latest
outputs:
build: ${{ steps.label-checks.outputs.build }}
linux: ${{ steps.label-checks.outputs.linux }}
win: ${{ steps.label-checks.outputs.win }}
macos: ${{ steps.label-checks.outputs.macos }}
steps:
- uses: actions/github-script@v6
id: label-checks
with:
script: |
const [owner, repo] = ["gear-tech", "gear"];
const { ref, payload: { issue: issue_number } } = context;
const { ref, payload: { number: issue_number } } = context;
// List all labels of the current pull request.
const { data: labelsArr } = await github.rest.issues.listLabelsOnIssue({
Expand All @@ -33,7 +38,7 @@ jobs:
labels.includes("E2-forcemacos")
];
if (linux == macos == false) return;
if (!(linux || macos)) return;
// List the latest check runs
const {
Expand All @@ -44,20 +49,25 @@ jobs:
ref,
});
for (const run in check_runs) {
if (run.name == "build) {
linux = (run.conclusion == "skipped");
} else if (run.name == "build / macos") {
macos = (run.conclusion == "skipped");
for (run of check_runs) {
if (run.name === "build / linux") {
linux = false;
} else if (run.name === "build / macos") {
macos = false;
}
}
const build = linux || macos;
return { build, linux, win: linux, macos }
core.setOutput("build", linux || macos);
core.setOutput("linux", linux);
core.setOutput("win", linux);
core.setOutput("macos", 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 }}
build:
needs: status
uses: ./.github/workflows/build.yml
if: ${{ needs.status.outputs.build }}
with:
cache: true
linux: ${{ needs.status.outputs.linux }}
win: ${{ needs.status.outputs.win }}
macos: ${{ needs.status.outputs.macos }}

0 comments on commit cfb9722

Please sign in to comment.