Skip to content

Commit 4648212

Browse files
authored
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
1 parent 354dc08 commit 4648212

20 files changed

Lines changed: 15908 additions & 263 deletions

File tree

.github/workflows/test.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
strategy:
1515
matrix:
1616
os:
17-
- macos-latest
1817
- ubuntu-latest
1918
- windows-latest
2019
cache:
21-
- true
22-
- false
20+
- with-cache
21+
- without-cache
2322
runs-on: ${{ matrix.os }}
2423
steps:
2524
- name: 🏗 Setup repo
@@ -29,9 +28,9 @@ jobs:
2928
uses: ./
3029
with:
3130
eas-version: latest
32-
eas-cache: ${{ matrix.cache }}
31+
eas-cache: ${{ matrix.cache == 'with-cache' }}
3332
expo-version: latest
34-
expo-cache: ${{ matrix.cache }}
33+
expo-cache: ${{ matrix.cache == 'with-cache' }}
3534
token: ${{ secrets.EXPO_TOKEN }}
3635

3736
- name: 🧪 EAS installed
@@ -45,4 +44,44 @@ jobs:
4544

4645
- name: 🧪 Expo authenticated
4746
run: expo whoami
47+
48+
preview-comment:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: 🏗 Setup repo
52+
uses: actions/checkout@v2
53+
54+
- name: 🏗 Setup Expo
55+
uses: ./
56+
with:
57+
eas-version: latest
58+
expo-version: latest
59+
token: ${{ secrets.EXPO_TOKEN }}
60+
61+
- name: 🏗 Setup project
62+
run: expo init -t blank ./temp
63+
64+
- name: 🧪 Without commenting
65+
uses: ./preview-comment
66+
id: preview
67+
with:
68+
project: ./temp
69+
comment: false
70+
71+
- name: 🧪 Output has content
72+
uses: actions/github-script@v5
73+
with:
74+
script: |
75+
const message = `${{ steps.preview.outputs.message }}`
76+
if (!message) throw new Error('Message output is empty')
77+
78+
- name: 🧪 Comment on PR
79+
uses: ./preview-comment
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
EXPO_TEST_GITHUB_PULL: 149
83+
with:
84+
project: ./temp
85+
channel: test
86+
4887

README.md

Lines changed: 94 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<h1>expo github action</h1>
2+
<h1>expo-github-action</h1>
33
<p>Publish, build or manage your <a href="https://github.com/expo/expo">Expo</a> app with GitHub Actions!</p>
44
<p>
55
<a href="https://github.com/expo/expo-github-action/releases">
@@ -13,56 +13,52 @@
1313
</a>
1414
</p>
1515
<p align="center">
16-
<a href="https://github.com/expo/expo-github-action#configuration-options"><b>Usage</b></a>
16+
<a href="#configuration-options"><b>Usage</b></a>
1717
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;
18-
<a href="https://github.com/expo/expo-github-action#example-workflows"><b>Examples</b></a>
18+
<a href="#example-workflows"><b>Examples</b></a>
1919
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;
20-
<a href="https://github.com/expo/expo-github-action#things-to-know"><b>Caveats</b></a>
20+
<a href="#things-to-know"><b>Caveats</b></a>
2121
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;
22-
<a href="https://github.com/expo/expo-github-action/blob/main/CHANGELOG.md"><b>Changelog</b></a>
22+
<a href="/blob/main/CHANGELOG.md"><b>Changelog</b></a>
2323
</p>
2424
</div>
2525

2626
## What's inside?
2727

2828
With this Expo action, you have full access to [Expo CLI][link-expo-cli] and [EAS CLI][link-eas-cli].
29-
It allows you to fully automate the `expo publish` or `eas build` process, leaving you with more time available for your project.
30-
There are some additional features included to make the usage of this action as simple as possible, like caching and authentication.
29+
It lets you automate the `expo publish` or `eas build` commands, leaving you with more time to work on your project.
30+
Some additional features are included to make the usage of this action as simple as possible, like caching and authentication.
3131

3232
## Configuration options
3333

34-
This action is customizable through variables; they are defined in the [`action.yml`](action.yml).
35-
Here is a summary of all the variables that you can use and their purpose.
34+
This action is customizable through variables defined in the [`action.yml`](action.yml).
35+
Here is a summary of all the input options you can use.
3636

37-
| variable | default | description |
38-
| ---------------- | ------- | ------------------------------------------------------------------------------------ |
39-
| `expo-version` | - | [Expo CLI](https://github.com/expo/expo-cli) version to install, skips when omitted. |
40-
| `expo-cache` | `true` | If it should use the [GitHub actions cache](#using-the-built-in-cache). |
41-
| `eas-version` | - | [EAS CLI](https://github.com/expo/eas-cli) version to install, skips when omitted. |
42-
| `eas-cache` | `true` | If it should use the [GitHub actions cache](#using-the-built-in-cache). |
43-
| `packager` | `yarn` | The package manager to use. _(e.g. `yarn` or `npm`)_ |
44-
| `token` | - | The token of your Expo account |
45-
| `patch-watchers` | `true` | If it should [patch the `fs.inotify.` limits](#enospc-errors-on-linux). |
46-
47-
> Never hardcode `expo-token` in your workflow, use [secrets][link-actions-secrets] to store them.
48-
49-
> Using `latest` for `eas-version` is recommened, you should always have the latest version of this CLI installed.
37+
| variable | default | description |
38+
| ------------------ | ------- | --------------------------------------------------------------------------------------------- |
39+
| **expo-version** | - | Expo CLI version to install _(skips when omitted)_ |
40+
| **expo-cache** | `true` | If it should use the GitHub actions cache ([read more](#using-the-built-in-cache)) |
41+
| **eas-version** | - | EAS CLI version to install _(skips when omitted)_ |
42+
| **eas-cache** | `true` | If it should use the GitHub actions cache ([read more](#using-the-built-in-cache)) |
43+
| **packager** | `yarn` | Package manager to use _(e.g. `yarn` or `npm`)_ |
44+
| **token** | - | Token of your Expo account _(only use with [secrets][link-actions-secrets])_ |
45+
| **patch-watchers** | `true` | If it should patch the `fs.inotify.*` limits on Ubuntu ([read more](#enospc-errors-on-linux)) |
5046

5147
## Example workflows
5248

53-
Before you dive into the workflow examples, you should know the basics of GitHub Actions.
49+
Before diving into the workflow examples, you should know the basics of GitHub Actions.
5450
You can read more about this in the [GitHub Actions documentation][link-actions].
5551

5652
1. [Publish on any push to main](#publish-on-any-push-to-main)
5753
2. [Creating a new EAS build](#creating-a-new-eas-build)
58-
3. [Test PRs and publish a review version](#test-prs-and-publish-a-review-version)
59-
4. [Test PRs on multiple nodes and systems](#test-prs-on-multiple-node-versions-and-systems)
54+
3. [Publish a preview from PR](#publish-a-preview-from-PR)
6055

6156
### Publish on any push to main
6257

63-
Below you can see the example configuration to publish whenever the main branch is updated.
64-
The workflow listens to the `push` event and sets up Node 14 using the [Setup Node Action][link-actions-node].
65-
It also auto-authenticates when the `token` is provided.
58+
This workflow listens to the `push` event on the `main` branch.
59+
It sets up all required components to publish the app, including authentication with a token.
60+
61+
> Always use [secrets][link-actions-secrets] when using tokens.
6662
6763
```yml
6864
on:
@@ -73,26 +69,35 @@ jobs:
7369
publish:
7470
runs-on: ubuntu-latest
7571
steps:
76-
- uses: actions/checkout@v2
77-
- uses: actions/setup-node@v2
72+
- name: 🏗 Setup repo
73+
uses: actions/checkout@v2
74+
75+
- name: 🏗 Setup Node
76+
uses: actions/setup-node@v2
7877
with:
7978
node-version: 16.x
8079
cache: yarn
81-
- uses: expo/expo-github-action@v6
80+
81+
- name: 🏗 Setup Expo
82+
uses: expo/expo-github-action@v7
8283
with:
8384
expo-version: 5.x
8485
token: ${{ secrets.EXPO_TOKEN }}
85-
- run: yarn install
86-
- run: expo publish
86+
87+
- name: 📦 Install dependencies
88+
run: yarn install
89+
90+
- name: 🚀 Publish app
91+
run: expo publish
8792
```
8893
8994
### Creating a new EAS build
9095
91-
You can also install [EAS](https://docs.expo.dev/eas/) CLI with this GitHub Action.
92-
Below we've swapped `expo-version` with `eas-version`, but you can also use them together.
93-
Both the `token` and `username`/`password` is shared between both Expo and EAS CLI.
96+
This action also allows you to install the EAS CLI.
97+
To do this, add the **eas-version** property, and the action will install it.
98+
We recommend using `latest` for the EAS CLI.
9499

95-
> We recommend using `latest` for `eas-version` to always have the most up-to-date version.
100+
> The **token** is shared for both Expo and EAS CLI.
96101

97102
```yml
98103
on:
@@ -103,107 +108,97 @@ jobs:
103108
build:
104109
runs-on: ubuntu-latest
105110
steps:
106-
- uses: actions/checkout@v2
107-
- uses: actions/setup-node@v2
111+
- name: 🏗 Setup repo
112+
uses: actions/checkout@v2
113+
114+
- name: 🏗 Setup Node
115+
uses: actions/setup-node@v2
108116
with:
109117
node-version: 16.x
110118
cache: yarn
111-
- uses: expo/expo-github-action@v6
119+
120+
- name: 🏗 Setup Expo
121+
uses: expo/expo-github-action@v7
112122
with:
113123
eas-version: latest
124+
expo-version: 5.x
114125
token: ${{ secrets.EXPO_TOKEN }}
115-
- run: yarn install
116-
- run: eas build
126+
127+
- name: 📦 Install dependencies
128+
run: yarn install
129+
130+
- name: 🚀 Build app
131+
run: eas build
117132
```
118133

119-
### Test PRs and publish a review version
134+
### Publish a preview from PR
120135

121-
Reviewing pull requests can take some time if you have to read every line of code.
122-
To make this easier, you can publish the edited version of the PR using a [release channel][link-expo-release-channels].
123-
Below you can see an example of a workflow that publishes and comments on te PR when the app is published.
136+
Reviewing pull requests can take some time.
137+
The reviewer needs to check out the branch, install the changes, and run the bundler to review the results.
138+
You can also automatically publish the project for the reviewer to skip those manual steps.
139+
140+
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.
141+
142+
> See the [preview-comment docs](./preview-comment).
124143

125144
```yml
126145
on: [pull_request]
127-
env:
128-
projectOwner: bycedric
129-
projectSlug: use-expo
130146
jobs:
131147
publish:
132148
runs-on: ubuntu-latest
133149
steps:
134-
- uses: actions/checkout@v2
135-
- uses: actions/setup-node@v2
150+
- name: 🏗 Setup repo
151+
uses: actions/checkout@v2
152+
153+
- name: 🏗 Setup Node
154+
uses: actions/setup-node@v2
136155
with:
137156
node-version: 16.x
138157
cache: yarn
139-
- uses: expo/expo-github-action@v6
158+
159+
- name: 🏗 Setup Expo
160+
uses: expo/expo-github-action@v7
140161
with:
141162
expo-version: 5.x
142163
token: ${{ secrets.EXPO_TOKEN }}
143-
- run: yarn install
144-
- run: expo publish --release-channel=pr-${{ github.event.number }}
145-
- uses: unsplash/comment-on-pr@v1.1.1
146-
env:
147-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148-
with:
149-
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>
150-
```
151-
152-
### Test PRs on multiple node versions and systems
153164
154-
With GitHub Actions, it's reasonably easy to set up a matrix build and test the app on multiple environments.
155-
These matrixes can help to make sure your app runs smoothly on a broad set of different development machines.
165+
- name: 📦 Install dependencies
166+
run: yarn install
156167
157-
> If you don't need automatic authentication, you can omit the `token` variables.
168+
- name: 🚀 Publish preview
169+
run: expo publish --release-channel=pr-${{ github.event.number }}
158170
159-
```yml
160-
on: [pull_request]
161-
jobs:
162-
ci:
163-
runs-on: ${{ matrix.os }}
164-
strategy:
165-
matrix:
166-
os: [ubuntu-latest, macOS-latest, windows-latest]
167-
node: [14.x, 16.x]
168-
steps:
169-
- uses: actions/checkout@v2
170-
- uses: actions/setup-node@v2
171-
with:
172-
node-version: ${{ matrix.node }}
173-
cache: yarn
174-
- uses: expo/expo-github-action@v6
171+
- name: 💬 Comment preview
172+
uses: expo/expo-github-action/preview-comment@v7
173+
env:
174+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175175
with:
176-
expo-version: 5.x
177-
- run: yarn install
178-
- run: yarn test
179-
- run: expo doctor
176+
channel: pr-${{ github.event.number }}
180177
```
181178

182179
## Things to know
183180

184181
### Automatic Expo login
185182

186-
You need to authenticate for some Expo commands like `expo publish` and `expo build`.
187-
This action can export the `EXPO_TOKEN` variable to access it in every step.
183+
Some Expo commands, like `expo publish` and `eas build`, require you to be authenticated.
184+
This action exports the **token** to ensure you are authenticated in every workflow step.
188185

189-
> Note, this action does not store the token anywhere. For every seperate job, you need to setup the token.
186+
> Note, this action does not store the token anywhere. Each separate workflow job needs to set up the **token** individually.
190187

191188
### Using the built-in cache
192189

193-
You can opt-in to caching the installation, making it a lot faster.
194-
Under the hood, it uses the [`@actions/cache`][link-actions-cache-package] package to restore the Expo CLI installation.
195-
This action generates a unique cache key for the OS, used packager, and exact version of the Expo CLI.
190+
You can opt-out from caching the Expo and EAS CLI installations.
191+
Under the hood, it uses the [`@actions/cache`][link-actions-cache-package] package to restore a previous install.
192+
It reduces the installation time because it only needs to download and extract a single tar file.
196193

197-
> Note, this cache will count towards your [repo cache limit][link-actions-cache-limit]. The Expo and EAS CLI are stored in different caches.
194+
> 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.
198195

199196
### ENOSPC errors on Linux
200197

201-
When you run `expo publish` or `expo build`, a new bundle is created.
202-
Creating these bundles require quite some resources.
203-
As of writing, GitHub actions has some small default values for the `fs.inotify` settings.
204-
Inside this action, we included a patch that increases these limits for the current workflow.
205-
It increases the `max_user_instances`, `max_user_watches` and `max_queued_events` to `524288`.
206-
You can disable this patch by setting the `patch-watchers` to `false`.
198+
Creating new bundles with Metro can be memory intensive.
199+
In the past, some builds resulted in `ENOSPC` errors.
200+
To prevent anyone from running into this, we make sure Ubuntu has sensible defaults in terms of file system availability.
201+
You can opt-out from patching the file system by setting **patch-watchers** to `false`.
207202

208203
<div align="center">
209204
<br />
@@ -214,8 +209,8 @@ You can disable this patch by setting the `patch-watchers` to `false`.
214209
[link-actions]: https://help.github.com/en/categories/automating-your-workflow-with-github-actions
215210
[link-actions-cache-limit]: https://github.com/actions/cache#cache-limits
216211
[link-actions-cache-package]: https://github.com/actions/toolkit/tree/main/packages/cache
217-
[link-actions-node]: https://github.com/actions/setup-node
218212
[link-actions-secrets]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
219213
[link-expo-cli]: https://docs.expo.dev/workflow/expo-cli/
220214
[link-expo-release-channels]: https://docs.expo.dev/distribution/release-channels/
221215
[link-eas-cli]: https://github.com/expo/eas-cli#readme
216+
[link-preview-comment]: https://github.com/expo/expo-github-action/pull/149#issuecomment-1013184520

0 commit comments

Comments
 (0)