Conditional actions in GitHub Workflows
When modeling complex tasks in a workflow, you sometimes might want not to execute a specific step – depending on the context. Let’s have a (simplified) example.
Using a build matrix, we build a debug and release version of the app.
1 2 3 |
strategy: matrix: build_type: [release, debug] |
This workflow will be executed twice; each run will have a unique value stored in the build_type
context variable. First one “development” and the second one “release.”
We want however only the “release” build to be uploaded to the AppStore.
1 |
if: ${{ matrix.build_type == 'release' }} |
This step will be executed only when the defined condition is met.
Complete workflow:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
on: push: jobs: build: runs-on: ubuntu-latest strategy: matrix: build_type: [release, debug] steps: - name: App build run: | tabris build ios --${{ matrix.build_type }} - name: AppStore upload if: ${{ matrix.build_type == 'release' }} run: | xcrun altool --upload-app --type ios \ --file build/cordova/platforms/ios/build/device/*.ipa |
We make use of these features in our Tabris.js Hello World app nightly builds. Take a look at the repository and see how our workflows look like.
Check out other posts about using deploy keys on Github Actions and how do we manage Apple certificates and provisioning profiles if you haven’t done it yet. With that knowledge, you will be able to quickly set up an iOS build job of your app on Github.
Let us know about your thoughts and if you’re interested in more build-related topics.
Feedback is welcome!
Want to join the discussion?Feel free to contribute!