From 333036dd0dedaaa40ef87a8b491ac44cfbb1606f Mon Sep 17 00:00:00 2001 From: dominhquang Date: Fri, 13 Sep 2024 17:38:53 +0700 Subject: [PATCH] [Issue-1753] Optimize build time --- .github/workflows/build-internal.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-internal.yml b/.github/workflows/build-internal.yml index faffe0912..c4e7d474b 100644 --- a/.github/workflows/build-internal.yml +++ b/.github/workflows/build-internal.yml @@ -5,14 +5,26 @@ on: branches: [ "koni-dev", "upgrade-ui" ] jobs: + check-runner: + runs-on: macos-13 + outputs: + runner-label: ${{ steps.set-runner.outputs.runner-label }} + + steps: + - name: Set runner + id: set-runner + run: | + runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners") + available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")') + if [ -n "$available" ]; then + echo "runner-label=self-hosted" >> $GITHUB_OUTPUT + else + echo "runner-label=macos-13" >> $GITHUB_OUTPUT + fi # iOS build workflow ------------------------------------------------- build-ios: name: iOS builds - runs-on: - - labels: [self-hosted] - timeout-minutes: 0 - - labels: [macos-13] - timeout-minutes: 10 + runs-on: ${{ needs.check-runner.outputs.runner-label }} env: GH_PAT: ${{ secrets.GH_PAT }} GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }}