Skip to content

Instantly share code, notes, and snippets.

@arthurpalves
Last active July 5, 2022 12:20
Show Gist options
  • Save arthurpalves/d42b3af1a90eac9b1d8d843c357be652 to your computer and use it in GitHub Desktop.
Save arthurpalves/d42b3af1a90eac9b1d8d843c357be652 to your computer and use it in GitHub Desktop.
Sample of Github Actions workflows for iOS that falls under our "Branching strategy" category. These are workflows whose triggers are changes in or towards certain branches.
name: ios/deploy
#
# GOOD TO KNOW
#
# This workflow is supposed to:
# 1. Help ensure the quality of the code changes; and
# 2. Deploy a variant of this application depending on
# which branch was changed.
#
# However, what determines the expected quality level
# and deployment are tasks performed by Fastlane, which
# this workflow uses.
#
# Such Fastlane setup IS NOT PROVIDED as part of this sample.
#
#
# TRIGGERS
#
# As seen below, this workflow is triggered given a single event:
# 1. On every push to branches `main`, `release/*` or `develop`
# (i.e.: On every single change to one of these branches).
#
on:
push:
branches: [ main, release/**, develop ]
#
# XCODE
#
# Given this workflow is for an iOS project, we specify the
# `DEVELOPER_DIR` of a given Xcode version available on Github's
# macOS runner.
#
# For more information on versions available, see:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11.0-Readme.md
#
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
jobs:
#
# JOBS
#
# We define a single job, named `build`.
# This has proven sufficient for our needs, but there can
# be multiple jobs. They run either in parallel or they can
# depend on each other.
#
# For more details, see:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds
#
build:
runs-on: macos-latest
steps:
#
# CHECKOUT
#
# This action checks-out your repository under $GITHUB_WORKSPACE,
# so your workflow can access it.
#
# This is mandatory, as we're gonna perform tasks using the code
# within the repository.
#
- uses: actions/checkout@v2
#
# CACHING PODS
#
# This step isn't mandatory, but it saves time.
# It caches the `Pods/` folder to improve workflow execution time.
#
- uses: actions/cache@v1
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
# ⬆️
# WHAT THIS IS USUALLY RESERVED FOR
#
# Prior to using Fastlane to perform a certain amount of tasks,
# either using one or multiple lanes, you can use steps to
# install dependencies that are not available on Github's macOS
# runner by default. Or use other actions directly here.
#
# A good example is an internal action we run to switch the variant
# of our app depending on the branch changed and bump it's version:
# - Deploy `TEST` variant if the changes occurred to `develop`.
# - Deploy `STG` variant if the changes occurred to `release/*`.
# - Deploy `PROD` variant if the changes occurred to `main`.
#
# Each variant contains the information which determines the backend
# environment it connects to, adjustments to name and bundle IDs, its
# export method, as well as the store it should be deployed to
# (AppCenter, TestFlight, AppStore).
# ⬇️
#
# FASTLANE EXECUTION
#
# `deploy` is a variant agnostic lane created to perform all the
# quality related tasks to the codebase AND deploy the
# application to it's desired store.
#
# It also uploads dsym to Firebase once deployment is successful.
#
# This is merely an example. You can run fastlane with your own
# lanes or use something completely different.
#
# It is also possible to run shell commands with your own step:
#
# ```
# - name: Clean install dependencies and build
# run: |
# npm ci
# npm run build
# ```
#
# For more information, see:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idsteps
#
- name: fastlane deploy
uses: maierj/fastlane-action@v1.4.0
#
# ENVIRONMENT VARIABLES
#
# Environment variables can be set at any moment:
# - Globally, as we see at the top with `DEVELOPER_DIR`
# - Or locally to a step, as below.
env:
AN_ENVIRONMENT_VARIABLE: ${{ secrets.A_SECRET_VALUE }}
with:
lane: deploy
skip-tracking: false
name: ios/feature-branch
#
# GOOD TO KNOW
#
# This workflow is supposed to help ensure the quality
# of the code changes attempted to be merged to branch
# `develop`.
#
# However, what determines the expected quality level
# are tasks performed by Fastlane, which this workflow
# uses. Such Fastlane setup IS NOT PROVIDED as part of
# this sample.
#
#
# TRIGGERS
#
# As seen below, this workflow is triggered given a few events happen:
# 1. When a Pull Request to branch `develop` is first opened;
# 2. Whenever new changes are pushed to an existing Pull Request to branch `develop`.
#
on:
pull_request:
types: [ opened, synchronize ]
branches: [ develop ]
#
# XCODE
#
# Given this workflow is for an iOS project, we specify the
# `DEVELOPER_DIR` of a given Xcode version available on Github's
# macOS runner.
#
# For more information on versions available, see:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11.0-Readme.md
#
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
jobs:
#
# JOBS
#
# We define a single job, named `build`.
# This has proven sufficient for our needs, but there can
# be multiple jobs. They run either in parallel or they can
# depend on each other.
#
# For more details, see:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds
#
build:
runs-on: macos-latest
steps:
#
# CHECKOUT
#
# This action checks-out your repository under $GITHUB_WORKSPACE,
# so your workflow can access it.
#
# This is mandatory, as we're gonna perform tasks using the code
# within the repository.
#
- uses: actions/checkout@v2
#
# CACHING PODS
#
# This step isn't mandatory, but it saves time.
# It caches the `Pods/` folder to improve workflow execution time.
#
- uses: actions/cache@v1
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
# ⬆️
# WHAT THIS IS USUALLY RESERVED FOR
#
# Prior to using Fastlane to perform a certain amount of tasks,
# either using one or multiple lanes, you can use steps to
# install dependencies that are not available on Github's macOS
# runner by default. Or use other actions directly here.
# ⬇️
#
# FASTLANE EXECUTION
#
# `run_all_but_deploy` is a lane created to perform all the
# quality related tasks to the codebase but not deploy the
# application anywhere.
#
# It is merely an example. You can run fastlane with your own
# lanes or use something completely different.
#
# It is also possible to run shell commands with your own step:
#
# ```
# - name: Clean install dependencies and build
# run: |
# npm ci
# npm run build
# ```
#
# For more information, see:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idsteps
#
- name: fastlane run_all_but_deploy
uses: maierj/fastlane-action@v1.4.0
#
# ENVIRONMENT VARIABLES
#
# Environment variables can be set at any moment:
# - Globally, as we see at the top with `DEVELOPER_DIR`
# - Or locally to a step, as below.
env:
AN_ENVIRONMENT_VARIABLE: ${{ secrets.A_SECRET_VALUE }}
with:
lane: run_all_but_deploy
skip-tracking: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment