From 379b475d9429dc039bd05bfad4e65bc8cd4a3965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zi=C3=B3=C5=82kowski?= Date: Mon, 25 Mar 2024 14:01:55 +0100 Subject: [PATCH] skip steps if build is not required --- .github/workflows/build_and_run_sherlo.yml | 114 ++++++++++++--------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build_and_run_sherlo.yml b/.github/workflows/build_and_run_sherlo.yml index 1458e1aa..a13eb786 100644 --- a/.github/workflows/build_and_run_sherlo.yml +++ b/.github/workflows/build_and_run_sherlo.yml @@ -16,38 +16,44 @@ on: jobs: android_preview_build: + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'sherlo') || contains(github.event.pull_request.labels.*.name, 'sherlo:skip_build'))) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: ref: ${{ github.ref }} - # - name: Set up Node.js - # uses: actions/setup-node@v2 - # with: - # node-version: '18.18.0' + - name: Set up Node.js + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: actions/setup-node@v2 + with: + node-version: '18.18.0' - # - name: Setup Java Environment - # uses: actions/setup-java@v2 - # with: - # java-version: '17' - # distribution: 'temurin' + - name: Setup Java Environment + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'temurin' - # - name: Install dependencies - # run: yarn + - name: Install dependencies + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + run: yarn - # - name: Build dependencies - # run: yarn build + - name: Build dependencies + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + run: yarn build - # - name: Setup EAS - # uses: expo/expo-github-action@v8 - # with: - # eas-version: latest - # token: ${{ secrets.EXPO_TOKEN }} + - name: Setup EAS + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: expo/expo-github-action@v8 + with: + eas-version: latest + token: ${{ secrets.EXPO_TOKEN }} - # - name: Build Android example app - # add condition to not build if sherlo:only_test - # run: yarn workspace @sherlo/expo-example android:build:preview + - name: Build Android example app + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + run: yarn workspace @sherlo/expo-example android:build:preview - name: Upload Android Artifact uses: actions/upload-artifact@v2 @@ -56,45 +62,53 @@ jobs: path: examples/expo-example/builds/preview/android.apk ios_preview_build: + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'sherlo') || contains(github.event.pull_request.labels.*.name, 'sherlo:skip_build'))) }} runs-on: macos-13 steps: - uses: actions/checkout@v2 with: ref: ${{ github.ref }} - # - name: Set up Node.js - # uses: actions/setup-node@v2 - # with: - # node-version: '18.18.0' - - # - name: Select Xcode Version - # uses: maxim-lobanov/setup-xcode@v1 - # with: - # xcode-version: '15.0.1' - # - run: | - # xcode-select -print-path - # - run: | - # xcodebuild -version + - name: Set up Node.js + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: actions/setup-node@v2 + with: + node-version: '18.18.0' - # - name: Setup Cocoapods - # uses: maxim-lobanov/setup-cocoapods@v1 - # with: - # version: latest + - name: Select Xcode Version + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.0.1' + - run: | + xcode-select -print-path + - run: | + xcodebuild -version + + - name: Setup Cocoapods + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: maxim-lobanov/setup-cocoapods@v1 + with: + version: latest - # - name: Install dependencies - # run: yarn + - name: Install dependencies + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + run: yarn - # - name: Build dependencies - # run: yarn build + - name: Build dependencies + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + run: yarn build - # - name: Setup EAS - # uses: expo/expo-github-action@v8 - # with: - # eas-version: latest - # token: ${{ secrets.EXPO_TOKEN }} + - name: Setup EAS + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + uses: expo/expo-github-action@v8 + with: + eas-version: latest + token: ${{ secrets.EXPO_TOKEN }} - # - name: Build iOS example app - # run: yarn workspace @sherlo/expo-example ios:build:preview + - name: Build iOS example app + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} + run: yarn workspace @sherlo/expo-example ios:build:preview - name: Upload iOS Artifact uses: actions/upload-artifact@v2 @@ -103,6 +117,7 @@ jobs: path: examples/expo-example/builds/preview/ios.tar.gz run_sherlo_action: + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'sherlo') || contains(github.event.pull_request.labels.*.name, 'sherlo:skip_build'))) }} runs-on: ubuntu-latest needs: [android_preview_build, ios_preview_build] steps: @@ -130,6 +145,7 @@ jobs: private_key: ${{ secrets.SHERLO_BOT_PRIVATE_KEY }} - name: Commit and push Preview builds + if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build')) }} env: BRANCH_NAME: ${{ github.event_name == 'pull_request' && github.head_ref || format('refs/heads/{0}', github.ref_name) }} run: |