From 1ef0114e94c51d10ff1d0dcbb7b38cf75b5ba253 Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Tue, 24 Mar 2026 11:39:13 +0100 Subject: [PATCH 1/2] refactor(ci): Extract platform-check into a reusable composite action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The platform-check step that decides whether to skip a build based on detect-changes outputs was duplicated across sample app workflows (sample-application.yml, sample-application-expo.yml) and across the build and test jobs within sample-application.yml. Extract the logic into a composite action at .github/actions/platform-check that takes the platform name, a sample_changed flag, and the needs_ios/needs_android/needs_web outputs as inputs, and returns a single skip output. The action handles the macOS → needs_ios mapping and includes a warning for unknown platforms. Replaces three inline bash scripts with a single reusable action. Closes #5865 --- .github/actions/platform-check/action.yml | 62 +++++++++++++++++++ .github/workflows/sample-application-expo.yml | 23 +++---- .github/workflows/sample-application.yml | 48 ++++---------- 3 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 .github/actions/platform-check/action.yml diff --git a/.github/actions/platform-check/action.yml b/.github/actions/platform-check/action.yml new file mode 100644 index 0000000000..aa422cdd76 --- /dev/null +++ b/.github/actions/platform-check/action.yml @@ -0,0 +1,62 @@ +name: 'Platform Check' +description: 'Decides whether to skip a build/test based on detect-changes outputs' + +inputs: + platform: + description: 'Target platform (ios, macos, android, web)' + required: true + sample_changed: + description: 'Whether the sample app itself changed (true/false)' + required: true + needs_ios: + description: 'detect-changes needs_ios output' + required: false + default: 'false' + needs_android: + description: 'detect-changes needs_android output' + required: false + default: 'false' + needs_web: + description: 'detect-changes needs_web output' + required: false + default: 'false' + +outputs: + skip: + description: 'Whether to skip this platform (true/false)' + value: ${{ steps.check.outputs.skip }} + +runs: + using: 'composite' + steps: + - name: Check if platform is needed + id: check + shell: bash + run: | + PLATFORM="${{ inputs.platform }}" + SAMPLE_CHANGED="${{ inputs.sample_changed }}" + + if [[ "$SAMPLE_CHANGED" == "true" ]]; then + echo "skip=false" >> "$GITHUB_OUTPUT" + echo "Sample app changed — building/testing $PLATFORM." + exit 0 + fi + + # macOS uses the iOS change-detection flag + case "$PLATFORM" in + ios|macos) NEEDS="${{ inputs.needs_ios }}" ;; + android) NEEDS="${{ inputs.needs_android }}" ;; + web) NEEDS="${{ inputs.needs_web }}" ;; + *) + echo "::warning::Unknown platform '$PLATFORM' — not skipping." + echo "skip=false" >> "$GITHUB_OUTPUT" + exit 0 + ;; + esac + + if [[ "$NEEDS" != "true" ]]; then + echo "skip=true" >> "$GITHUB_OUTPUT" + echo "Skipping $PLATFORM — no relevant changes detected." + else + echo "skip=false" >> "$GITHUB_OUTPUT" + fi diff --git a/.github/workflows/sample-application-expo.yml b/.github/workflows/sample-application-expo.yml index fa45424642..afe53b8dfc 100644 --- a/.github/workflows/sample-application-expo.yml +++ b/.github/workflows/sample-application-expo.yml @@ -61,22 +61,13 @@ jobs: steps: - name: Check if platform is needed id: platform-check - run: | - SAMPLE_CHANGED="${{ needs.detect-changes.outputs.sample_expo }}" - - if [[ "$SAMPLE_CHANGED" == "true" ]]; then - echo "skip=false" >> "$GITHUB_OUTPUT" - echo "Sample app changed — building ${{ matrix.platform }}." - elif [[ "${{ matrix.platform }}" == "ios" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping iOS — no relevant changes detected." - elif [[ "${{ matrix.platform }}" == "android" && "${{ needs.detect-changes.outputs.needs_android }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping Android — no relevant changes detected." - elif [[ "${{ matrix.platform }}" == "web" && "${{ needs.detect-changes.outputs.needs_web }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping Web — no relevant changes detected." - fi + uses: ./.github/actions/platform-check + with: + platform: ${{ matrix.platform }} + sample_changed: ${{ needs.detect-changes.outputs.sample_expo }} + needs_ios: ${{ needs.detect-changes.outputs.needs_ios }} + needs_android: ${{ needs.detect-changes.outputs.needs_android }} + needs_web: ${{ needs.detect-changes.outputs.needs_web }} - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 if: ${{ steps.platform-check.outputs.skip != 'true' }} diff --git a/.github/workflows/sample-application.yml b/.github/workflows/sample-application.yml index fe90ca546e..c01198be9d 100644 --- a/.github/workflows/sample-application.yml +++ b/.github/workflows/sample-application.yml @@ -76,27 +76,12 @@ jobs: steps: - name: Check if platform is needed id: platform-check - run: | - # Sample app changes should always build all platforms (that's the - # whole point of this workflow). The needs_ios/needs_android flags - # only track SDK source & native code — not sample app files. - SAMPLE_CHANGED="${{ needs.detect-changes.outputs.sample_react_native }}" - - if [[ "$SAMPLE_CHANGED" == "true" ]]; then - echo "skip=false" >> "$GITHUB_OUTPUT" - echo "Sample app changed — building ${{ matrix.platform }}." - elif [[ "${{ matrix.platform }}" == "ios" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping iOS — no relevant changes detected." - elif [[ "${{ matrix.platform }}" == "macos" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping macOS — no relevant changes detected." - elif [[ "${{ matrix.platform }}" == "android" && "${{ needs.detect-changes.outputs.needs_android }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping Android — no relevant changes detected." - else - echo "skip=false" >> "$GITHUB_OUTPUT" - fi + uses: ./.github/actions/platform-check + with: + platform: ${{ matrix.platform }} + sample_changed: ${{ needs.detect-changes.outputs.sample_react_native }} + needs_ios: ${{ needs.detect-changes.outputs.needs_ios }} + needs_android: ${{ needs.detect-changes.outputs.needs_android }} - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 if: ${{ steps.platform-check.outputs.skip != 'true' }} @@ -266,21 +251,12 @@ jobs: steps: - name: Check if platform is needed id: platform-check - run: | - SAMPLE_CHANGED="${{ needs.detect-changes.outputs.sample_react_native }}" - - if [[ "$SAMPLE_CHANGED" == "true" ]]; then - echo "skip=false" >> "$GITHUB_OUTPUT" - echo "Sample app changed — testing ${{ matrix.platform }}." - elif [[ "${{ matrix.platform }}" == "ios" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping iOS — no relevant changes detected." - elif [[ "${{ matrix.platform }}" == "android" && "${{ needs.detect-changes.outputs.needs_android }}" != "true" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Skipping Android — no relevant changes detected." - else - echo "skip=false" >> "$GITHUB_OUTPUT" - fi + uses: ./.github/actions/platform-check + with: + platform: ${{ matrix.platform }} + sample_changed: ${{ needs.detect-changes.outputs.sample_react_native }} + needs_ios: ${{ needs.detect-changes.outputs.needs_ios }} + needs_android: ${{ needs.detect-changes.outputs.needs_android }} - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 if: ${{ steps.platform-check.outputs.skip != 'true' }} From de5abd3c2ae6131824858aa51b5127ea8814121c Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Tue, 24 Mar 2026 13:48:42 +0100 Subject: [PATCH 2/2] fix(ci): Move checkout before platform-check composite action Local composite actions (uses: ./.github/actions/...) require the repository to be checked out first. Move the actions/checkout step before platform-check and make it unconditional so the action file is available when GitHub Actions resolves it. --- .github/workflows/sample-application-expo.yml | 5 ++--- .github/workflows/sample-application.yml | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sample-application-expo.yml b/.github/workflows/sample-application-expo.yml index afe53b8dfc..16c4138ef5 100644 --- a/.github/workflows/sample-application-expo.yml +++ b/.github/workflows/sample-application-expo.yml @@ -59,6 +59,8 @@ jobs: - platform: 'android' ios-use-frameworks: 'dynamic-frameworks' steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: Check if platform is needed id: platform-check uses: ./.github/actions/platform-check @@ -69,9 +71,6 @@ jobs: needs_android: ${{ needs.detect-changes.outputs.needs_android }} needs_web: ${{ needs.detect-changes.outputs.needs_web }} - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - if: ${{ steps.platform-check.outputs.skip != 'true' }} - - name: Enable Corepack (NPM) if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform != 'ios' }} run: npm i -g corepack diff --git a/.github/workflows/sample-application.yml b/.github/workflows/sample-application.yml index c01198be9d..61653c65aa 100644 --- a/.github/workflows/sample-application.yml +++ b/.github/workflows/sample-application.yml @@ -74,6 +74,8 @@ jobs: - ios-use-frameworks: 'dynamic-frameworks' platform: 'macos' steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: Check if platform is needed id: platform-check uses: ./.github/actions/platform-check @@ -83,9 +85,6 @@ jobs: needs_ios: ${{ needs.detect-changes.outputs.needs_ios }} needs_android: ${{ needs.detect-changes.outputs.needs_android }} - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - if: ${{ steps.platform-check.outputs.skip != 'true' }} - - name: Enable Corepack (NPM) if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'android' }} run: npm i -g corepack @@ -249,6 +248,8 @@ jobs: build-type: 'production' steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: Check if platform is needed id: platform-check uses: ./.github/actions/platform-check @@ -258,9 +259,6 @@ jobs: needs_ios: ${{ needs.detect-changes.outputs.needs_ios }} needs_android: ${{ needs.detect-changes.outputs.needs_android }} - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - if: ${{ steps.platform-check.outputs.skip != 'true' }} - - name: Install Maestro if: ${{ steps.platform-check.outputs.skip != 'true' }} uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0