Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/actions/platform-check/action.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 9 additions & 19 deletions .github/workflows/sample-application-expo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,17 @@ jobs:
- platform: 'android'
ios-use-frameworks: 'dynamic-frameworks'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- 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: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
if: ${{ steps.platform-check.outputs.skip != 'true' }}
uses: ./.github/actions/platform-check
Comment thread
lucas-zimerman marked this conversation as resolved.
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 }}

- name: Enable Corepack (NPM)
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform != 'ios' }}
Expand Down
58 changes: 16 additions & 42 deletions .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,16 @@ jobs:
- ios-use-frameworks: 'dynamic-frameworks'
platform: 'macos'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- 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: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
if: ${{ steps.platform-check.outputs.skip != 'true' }}
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 }}

- name: Enable Corepack (NPM)
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'android' }}
Expand Down Expand Up @@ -264,26 +248,16 @@ jobs:
build-type: 'production'

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- 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: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
if: ${{ steps.platform-check.outputs.skip != 'true' }}
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 }}

- name: Install Maestro
if: ${{ steps.platform-check.outputs.skip != 'true' }}
Expand Down
Loading