GitHub Action
Expo GitHub Action
Publish, build or manage your Expo app with GitHub Actions!
With this Expo action, you have full access to Expo CLI and EAS CLI.
It allows you to fully automate the expo publish
or eas build
process, leaving you with more time available for your project.
There are some additional features included to make the usage of this action as simple as possible, like caching and authentication.
This action is customizable through variables; they are defined in the action.yml
.
Here is a summary of all the variables that you can use and their purpose.
variable | default | description |
---|---|---|
expo-version |
'' |
Expo CLI version to install, skips when omitted. |
expo-cache |
true |
If it should use the GitHub actions cache. |
eas-version |
'' |
EAS CLI version to install, skips when omitted. |
eas-cache |
true |
If it should use the GitHub actions cache. |
packager |
yarn |
The package manager to use. (e.g. yarn or npm ) |
token |
'' |
The token of your Expo account |
patch-watchers |
true |
If it should patch the fs.inotify. limits. |
Never hardcode
expo-token
in your workflow, use secrets to store them.
Using
latest
foreas-version
is recommened, you should always have the latest version of this CLI installed.
Before you dive into the workflow examples, you should know the basics of GitHub Actions. You can read more about this in the GitHub Actions documentation.
- Publish on any push to main
- Creating a new EAS build
- Test PRs and publish a review version
- Test PRs on multiple nodes and systems
Below you can see the example configuration to publish whenever the main branch is updated.
The workflow listens to the push
event and sets up Node 14 using the Setup Node Action.
It also auto-authenticates when the token
is provided.
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn
- uses: expo/expo-github-action@v6
with:
expo-version: 5.x
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: expo publish
You can also install EAS CLI with this GitHub Action.
Below we've swapped expo-version
with eas-version
, but you can also use them together.
Both the token
and username
/password
is shared between both Expo and EAS CLI.
We recommend using
latest
foreas-version
to always have the most up-to-date version.
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn
- uses: expo/expo-github-action@v6
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: eas build
Reviewing pull requests can take some time if you have to read every line of code. To make this easier, you can publish the edited version of the PR using a release channel. Below you can see an example of a workflow that publishes and comments on te PR when the app is published.
on: [pull_request]
env:
projectOwner: bycedric
projectSlug: use-expo
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn
- uses: expo/expo-github-action@v6
with:
expo-version: 5.x
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: expo publish --release-channel=pr-${{ github.event.number }}
- uses: unsplash/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: App is ready for review, you can [see it here](https://expo.dev/@${{ env.projectOwner }}/${{ env.projectSlug }}?release-channel=pr-${{ github.event.number }}).\n\n<img src="https://qr.expo.dev/expo-go?owner=${{ env.projectOwner }}&slug=${{ env.projectSlug }}&releaseChannel=pr-${{ github.event.number }}" height="200px" width="200px"></a>
With GitHub Actions, it's reasonably easy to set up a matrix build and test the app on multiple environments. These matrixes can help to make sure your app runs smoothly on a broad set of different development machines.
If you don't need automatic authentication, you can omit the
token
variables.
on: [pull_request]
jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: yarn
- uses: expo/expo-github-action@v6
with:
expo-version: 5.x
- run: yarn install
- run: yarn test
- run: expo doctor
You need to authenticate for some Expo commands like expo publish
and expo build
.
This action can export the EXPO_TOKEN
variable to access it in every step.
Note, this action does not store the token anywhere. For every seperate job, you need to setup the token.
Caching is enabled by default to speed up consecutive CLI installs, but you can still opt-out to this.
Under the hood, it uses the @actions/cache
package to restore the CLI installation.
This action generates a unique cache key for the OS, used packager, and exact version of the CLI.
Note, this cache will count towards your repo cache limit. The Expo and EAS CLI are stored in different caches.
When you run expo publish
or expo build
, a new bundle is created.
Creating these bundles require quite some resources.
As of writing, GitHub actions has some small default values for the fs.inotify
settings.
Inside this action, we included a patch that increases these limits for the current workflow.
It increases the max_user_instances
, max_user_watches
and max_queued_events
to 524288
.
You can disable this patch by setting the patch-watchers
to false
.
with ❤️ byCedric