From cbf30015e67e323692bcc03bf20090d91370725d Mon Sep 17 00:00:00 2001 From: Tieu Long Date: Sun, 12 Apr 2026 21:51:16 +0700 Subject: [PATCH] refactor: move preflight to ubuntu-slim, skip build on non-star instead of failing --- .github/workflows/build-macos-image.yml | 28 +++++++++++++++-------- .github/workflows/build-recovery.yml | 30 ++++++++++++++++--------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-macos-image.yml b/.github/workflows/build-macos-image.yml index 207244d..4a1bf5f 100644 --- a/.github/workflows/build-macos-image.yml +++ b/.github/workflows/build-macos-image.yml @@ -34,23 +34,23 @@ on: - 'dmg' jobs: - build-macos-image: + preflight: if: ${{ inputs.macos_version != '' && inputs.image_format != '' }} - runs-on: macos-15-intel - timeout-minutes: 80 + runs-on: ubuntu-slim + timeout-minutes: 5 + outputs: + _build: ${{ steps.check.outputs._build }} steps: - name: Preflight + id: check run: | # Third time's the charm if [ "$GITHUB_RUN_ATTEMPT" -ge 3 ] || [ "$GITHUB_RUN_NUMBER" -ge 3 ]; then + echo "_build=true" >> $GITHUB_OUTPUT exit 0 fi - # Most users arrive directly at the Actions tab without reading the README, - # missing the prebuilt images in the Releases tab. Requiring a star (step 1 - # of the README) reduces redundant builds — and runner costs — for images - # that may already exist in a recent forks list. FOUND=false PAGE=1 while [ $PAGE -le 50 ]; do @@ -64,15 +64,25 @@ jobs: done if [ "$FOUND" = "false" ]; then + echo "_build=false" >> $GITHUB_OUTPUT echo "## Before you build — check if someone already did it for you :point_down:" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "Browse the **[Recent Forks List](https://github.com/LongQT-sea/mkmaciso/releases/latest)** — someone may have already built the macOS version you need." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "If you still need to build your own, star [the repo](https://github.com/LongQT-sea/mkmaciso) first — that's step 1 in the [README](https://github.com/LongQT-sea/macos-iso-builder#how-to-use). :star:" >> $GITHUB_STEP_SUMMARY + echo "Still need to build your own? Star [LongQT-sea/macos-iso-builder](https://github.com/LongQT-sea/macos-iso-builder), then re-run the workflow :star:" >> $GITHUB_STEP_SUMMARY echo "
![star](https://raw.githubusercontent.com/LongQT-sea/macos-iso-builder/main/.github/star.jpg)" >> $GITHUB_STEP_SUMMARY - exit 1 + exit 0 fi + echo "_build=true" >> $GITHUB_OUTPUT + + build-macos-image: + needs: preflight + if: needs.preflight.outputs._build == 'true' + runs-on: macos-15-intel + timeout-minutes: 80 + + steps: - name: Checkout repository uses: actions/checkout@v6 diff --git a/.github/workflows/build-recovery.yml b/.github/workflows/build-recovery.yml index a9ad029..bab0b64 100644 --- a/.github/workflows/build-recovery.yml +++ b/.github/workflows/build-recovery.yml @@ -24,25 +24,25 @@ on: type: string jobs: - build-recovery-iso: + preflight: if: ${{ inputs.macos_version != '' }} - runs-on: macos-latest + runs-on: ubuntu-slim permissions: contents: write # needed to create releases - timeout-minutes: 15 + timeout-minutes: 5 + outputs: + _build: ${{ steps.check.outputs._build }} steps: - name: Preflight + id: check run: | # Third time's the charm - if [ "$GITHUB_RUN_ATTEMPT" -ge 2 ] || [ "$GITHUB_RUN_NUMBER" -ge 2 ]; then + if [ "$GITHUB_RUN_ATTEMPT" -ge 3 ] || [ "$GITHUB_RUN_NUMBER" -ge 3 ]; then + echo "_build=true" >> $GITHUB_OUTPUT exit 0 fi - # Most users arrive directly at the Actions tab without reading the README, - # missing the prebuilt images in the Releases tab. Requiring a star (step 1 - # of the README) reduces redundant builds — and runner costs — for images - # that may already exist in a recent forks list. FOUND=false PAGE=1 while [ $PAGE -le 50 ]; do @@ -56,15 +56,25 @@ jobs: done if [ "$FOUND" = "false" ]; then + echo "_build=false" >> $GITHUB_OUTPUT echo "## Before you build — check if someone already did it for you :point_down:" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "Browse the **[Recent Forks List](https://github.com/LongQT-sea/mkmaciso/releases/latest)** — someone may have already built the macOS version you need." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "If you still need to build your own, star [the repo](https://github.com/LongQT-sea/mkmaciso) first — that's step 1 in the [README](https://github.com/LongQT-sea/macos-iso-builder#how-to-use). :star:" >> $GITHUB_STEP_SUMMARY + echo "Still need to build your own? Star [LongQT-sea/macos-iso-builder](https://github.com/LongQT-sea/macos-iso-builder), then re-run the workflow :star:" >> $GITHUB_STEP_SUMMARY echo "
![star](https://raw.githubusercontent.com/LongQT-sea/macos-iso-builder/main/.github/star.jpg)" >> $GITHUB_STEP_SUMMARY - exit 1 + exit 0 fi + echo "_build=true" >> $GITHUB_OUTPUT + + build-recovery-iso: + needs: preflight + if: needs.preflight.outputs._build == 'true' + runs-on: macos-latest + timeout-minutes: 15 + + steps: - name: Checkout repository uses: actions/checkout@v6