-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add comment qr code subaction (#149)
* feature: add comment subaction for qr code previews * chore: rebuild project * chore: setup test for comment subaction * fix: add missing metadata for the comment subaction * fix: path to entrypoint in comment subaction * fix: add test overwrite * fix: resolve the owner silently * fix: avoid double error: in failed actions * fix: add missing github token * chore: rebuild project * chore: rebuild project * fix: newline in project owner * feature: add outputs to allow customization and rename * fix: failing test * chore: rebuild project * chore: tweak the comment a bit more * docs: add documentation for preview comment * docs: add message about comment message id * docs: fix typo in output reuse * docs: add missing message id to outputs * docs: make steps a bit more readable * docs: update github actions version * chore: make test workflow more readable * test: add missing comment preview tests * chore: rebuild project * test: separate each output * docs: update readme * chore: remove unnecessary comments * docs: use new table format * docs: update name to match value in actions * docs: use relative path to preview-comment action * fix: use project owner in default comment id * docs: move unimportant stuff around * docs: last pass over readmes
- Loading branch information
Showing
20 changed files
with
15,908 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div align="center"> | ||
<h1>expo github action</h1> | ||
<h1>expo-github-action</h1> | ||
<p>Publish, build or manage your <a href="https://github.com/expo/expo">Expo</a> app with GitHub Actions!</p> | ||
<p> | ||
<a href="https://github.com/expo/expo-github-action/releases"> | ||
|
@@ -13,56 +13,52 @@ | |
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://github.com/expo/expo-github-action#configuration-options"><b>Usage</b></a> | ||
<a href="#configuration-options"><b>Usage</b></a> | ||
— | ||
<a href="https://github.com/expo/expo-github-action#example-workflows"><b>Examples</b></a> | ||
<a href="#example-workflows"><b>Examples</b></a> | ||
— | ||
<a href="https://github.com/expo/expo-github-action#things-to-know"><b>Caveats</b></a> | ||
<a href="#things-to-know"><b>Caveats</b></a> | ||
— | ||
<a href="https://github.com/expo/expo-github-action/blob/main/CHANGELOG.md"><b>Changelog</b></a> | ||
<a href="/blob/main/CHANGELOG.md"><b>Changelog</b></a> | ||
</p> | ||
</div> | ||
|
||
## What's inside? | ||
|
||
With this Expo action, you have full access to [Expo CLI][link-expo-cli] and [EAS CLI][link-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. | ||
It lets you automate the `expo publish` or `eas build` commands, leaving you with more time to work on your project. | ||
Some additional features are included to make the usage of this action as simple as possible, like caching and authentication. | ||
|
||
## Configuration options | ||
|
||
This action is customizable through variables; they are defined in the [`action.yml`](action.yml). | ||
Here is a summary of all the variables that you can use and their purpose. | ||
This action is customizable through variables defined in the [`action.yml`](action.yml). | ||
Here is a summary of all the input options you can use. | ||
|
||
| variable | default | description | | ||
| ---------------- | ------- | ------------------------------------------------------------------------------------ | | ||
| `expo-version` | - | [Expo CLI](https://github.com/expo/expo-cli) version to install, skips when omitted. | | ||
| `expo-cache` | `true` | If it should use the [GitHub actions cache](#using-the-built-in-cache). | | ||
| `eas-version` | - | [EAS CLI](https://github.com/expo/eas-cli) version to install, skips when omitted. | | ||
| `eas-cache` | `true` | If it should use the [GitHub actions cache](#using-the-built-in-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](#enospc-errors-on-linux). | | ||
|
||
> Never hardcode `expo-token` in your workflow, use [secrets][link-actions-secrets] to store them. | ||
> Using `latest` for `eas-version` is recommened, you should always have the latest version of this CLI installed. | ||
| variable | default | description | | ||
| ------------------ | ------- | --------------------------------------------------------------------------------------------- | | ||
| **expo-version** | - | Expo CLI version to install _(skips when omitted)_ | | ||
| **expo-cache** | `true` | If it should use the GitHub actions cache ([read more](#using-the-built-in-cache)) | | ||
| **eas-version** | - | EAS CLI version to install _(skips when omitted)_ | | ||
| **eas-cache** | `true` | If it should use the GitHub actions cache ([read more](#using-the-built-in-cache)) | | ||
| **packager** | `yarn` | Package manager to use _(e.g. `yarn` or `npm`)_ | | ||
| **token** | - | Token of your Expo account _(only use with [secrets][link-actions-secrets])_ | | ||
| **patch-watchers** | `true` | If it should patch the `fs.inotify.*` limits on Ubuntu ([read more](#enospc-errors-on-linux)) | | ||
|
||
## Example workflows | ||
|
||
Before you dive into the workflow examples, you should know the basics of GitHub Actions. | ||
Before diving into the workflow examples, you should know the basics of GitHub Actions. | ||
You can read more about this in the [GitHub Actions documentation][link-actions]. | ||
|
||
1. [Publish on any push to main](#publish-on-any-push-to-main) | ||
2. [Creating a new EAS build](#creating-a-new-eas-build) | ||
3. [Test PRs and publish a review version](#test-prs-and-publish-a-review-version) | ||
4. [Test PRs on multiple nodes and systems](#test-prs-on-multiple-node-versions-and-systems) | ||
3. [Publish a preview from PR](#publish-a-preview-from-PR) | ||
|
||
### Publish on any push to main | ||
|
||
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][link-actions-node]. | ||
It also auto-authenticates when the `token` is provided. | ||
This workflow listens to the `push` event on the `main` branch. | ||
It sets up all required components to publish the app, including authentication with a token. | ||
|
||
> Always use [secrets][link-actions-secrets] when using tokens. | ||
```yml | ||
on: | ||
|
@@ -73,26 +69,35 @@ jobs: | |
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- name: 🏗 Setup repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: 🏗 Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
cache: yarn | ||
- uses: expo/expo-github-action@v6 | ||
|
||
- name: 🏗 Setup Expo | ||
uses: expo/expo-github-action@v7 | ||
with: | ||
expo-version: 5.x | ||
token: ${{ secrets.EXPO_TOKEN }} | ||
- run: yarn install | ||
- run: expo publish | ||
|
||
- name: 📦 Install dependencies | ||
run: yarn install | ||
|
||
- name: 🚀 Publish app | ||
run: expo publish | ||
``` | ||
### Creating a new EAS build | ||
You can also install [EAS](https://docs.expo.dev/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. | ||
This action also allows you to install the EAS CLI. | ||
To do this, add the **eas-version** property, and the action will install it. | ||
We recommend using `latest` for the EAS CLI. | ||
|
||
> We recommend using `latest` for `eas-version` to always have the most up-to-date version. | ||
> The **token** is shared for both Expo and EAS CLI. | ||
|
||
```yml | ||
on: | ||
|
@@ -103,107 +108,97 @@ jobs: | |
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- name: 🏗 Setup repo | ||
uses: actions/checkout@v2 | ||
- name: 🏗 Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
cache: yarn | ||
- uses: expo/expo-github-action@v6 | ||
- name: 🏗 Setup Expo | ||
uses: expo/expo-github-action@v7 | ||
with: | ||
eas-version: latest | ||
expo-version: 5.x | ||
token: ${{ secrets.EXPO_TOKEN }} | ||
- run: yarn install | ||
- run: eas build | ||
- name: 📦 Install dependencies | ||
run: yarn install | ||
- name: 🚀 Build app | ||
run: eas build | ||
``` | ||
|
||
### Test PRs and publish a review version | ||
### Publish a preview from PR | ||
|
||
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][link-expo-release-channels]. | ||
Below you can see an example of a workflow that publishes and comments on te PR when the app is published. | ||
Reviewing pull requests can take some time. | ||
The reviewer needs to check out the branch, install the changes, and run the bundler to review the results. | ||
You can also automatically publish the project for the reviewer to skip those manual steps. | ||
|
||
This workflow publishes the changes on the `pr-#` [release channel][link-expo-release-channels] and adds a comment to the pull request once it's ready for review. | ||
|
||
> See the [preview-comment docs](./preview-comment). | ||
|
||
```yml | ||
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 | ||
- name: 🏗 Setup repo | ||
uses: actions/checkout@v2 | ||
- name: 🏗 Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
cache: yarn | ||
- uses: expo/expo-github-action@v6 | ||
- name: 🏗 Setup Expo | ||
uses: expo/expo-github-action@v7 | ||
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> | ||
``` | ||
|
||
### Test PRs on multiple node versions and systems | ||
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. | ||
- name: 📦 Install dependencies | ||
run: yarn install | ||
> If you don't need automatic authentication, you can omit the `token` variables. | ||
- name: 🚀 Publish preview | ||
run: expo publish --release-channel=pr-${{ github.event.number }} | ||
```yml | ||
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 | ||
- name: 💬 Comment preview | ||
uses: expo/expo-github-action/preview-comment@v7 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
expo-version: 5.x | ||
- run: yarn install | ||
- run: yarn test | ||
- run: expo doctor | ||
channel: pr-${{ github.event.number }} | ||
``` | ||
|
||
## Things to know | ||
|
||
### Automatic Expo login | ||
|
||
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. | ||
Some Expo commands, like `expo publish` and `eas build`, require you to be authenticated. | ||
This action exports the **token** to ensure you are authenticated in every workflow step. | ||
|
||
> Note, this action does not store the token anywhere. For every seperate job, you need to setup the token. | ||
> Note, this action does not store the token anywhere. Each separate workflow job needs to set up the **token** individually. | ||
|
||
### Using the built-in cache | ||
|
||
You can opt-in to caching the installation, making it a lot faster. | ||
Under the hood, it uses the [`@actions/cache`][link-actions-cache-package] package to restore the Expo CLI installation. | ||
This action generates a unique cache key for the OS, used packager, and exact version of the Expo CLI. | ||
You can opt-out from caching the Expo and EAS CLI installations. | ||
Under the hood, it uses the [`@actions/cache`][link-actions-cache-package] package to restore a previous install. | ||
It reduces the installation time because it only needs to download and extract a single tar file. | ||
|
||
> Note, this cache will count towards your [repo cache limit][link-actions-cache-limit]. The Expo and EAS CLI are stored in different caches. | ||
> Note, using cache will count towards your [repo cache limit][link-actions-cache-limit]. Both the Expo and EAS CLI are stored in different caches. | ||
|
||
### ENOSPC errors on Linux | ||
|
||
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`. | ||
Creating new bundles with Metro can be memory intensive. | ||
In the past, some builds resulted in `ENOSPC` errors. | ||
To prevent anyone from running into this, we make sure Ubuntu has sensible defaults in terms of file system availability. | ||
You can opt-out from patching the file system by setting **patch-watchers** to `false`. | ||
|
||
<div align="center"> | ||
<br /> | ||
|
@@ -214,8 +209,8 @@ You can disable this patch by setting the `patch-watchers` to `false`. | |
[link-actions]: https://help.github.com/en/categories/automating-your-workflow-with-github-actions | ||
[link-actions-cache-limit]: https://github.com/actions/cache#cache-limits | ||
[link-actions-cache-package]: https://github.com/actions/toolkit/tree/main/packages/cache | ||
[link-actions-node]: https://github.com/actions/setup-node | ||
[link-actions-secrets]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets | ||
[link-expo-cli]: https://docs.expo.dev/workflow/expo-cli/ | ||
[link-expo-release-channels]: https://docs.expo.dev/distribution/release-channels/ | ||
[link-eas-cli]: https://github.com/expo/eas-cli#readme | ||
[link-preview-comment]: https://github.com/expo/expo-github-action/pull/149#issuecomment-1013184520 |
Oops, something went wrong.