Skip to content

Instantly share code, notes, and snippets.

@axeldelafosse
Last active March 22, 2023 11:06
Show Gist options
  • Save axeldelafosse/d7dc05dfc5299527662a958f9071e123 to your computer and use it in GitHub Desktop.
Save axeldelafosse/d7dc05dfc5299527662a958f9071e123 to your computer and use it in GitHub Desktop.
Expo Preview Deployment for your PRs. For Expo Managed
name: Expo Preview
on: [pull_request]
jobs:
preview:
name: Deploy Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Configure Expo
uses: expo/expo-github-action@v5
with:
expo-version: 4.x
expo-token: ${{ secrets.EXPO_TOKEN }}
expo-cache: true
- name: Yarn install
run: yarn install
- name: Expo publish
run: expo publish --release-channel=pr-${{ github.event.number }}
- name: Get Expo preview URL
id: expo
run: echo "::set-output name=path::@${{ secrets.EXPO_USERNAME }}/projects/${{ secrets.EXPO_PROJECTNAME }}?release-channel=pr-${{ github.event.number }}"
- name: Get Expo manifest URL
id: expo-manifest
run: echo "::set-output name=path::@${{ secrets.EXPO_USERNAME }}/${{ secrets.EXPO_PROJECTNAME }}?release-channel=pr-${{ github.event.number }}"
- name: Notify
uses: peter-evans/create-or-update-comment@v1
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened') }}
with:
issue-number: ${{ github.event.number }}
body: |
This pull request preview deployment is now available.
✅ Preview: [https://expo.io/${{ steps.expo.outputs.path }}](https://expo.io/${{ steps.expo.outputs.path }})
<a href="https://exp.host/${{ steps.expo-manifest.outputs.path }}"><img src="https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=exp://exp.host/${{ steps.expo-manifest.outputs.path }}" height="200px" width="200px"></a>
@axeldelafosse
Copy link
Author

Add this file to the .github/workflows folder in your repository.

You need to add EXPO_TOKEN, EXPO_USERNAME and EXPO_PROJECTNAME to your GitHub repo secrets:

  • EXPO_TOKEN is an access token that you can create in the settings
  • EXPO_USERNAME is your username
  • EXPO_PROJECTNAME is your project name, i.e. your app slug

If you have a monorepo, you can specify the working-directory like this:

name: Expo Preview

defaults:
  run:
    working-directory: packages/app/

More info on GitHub Actions and Expo GitHub Actions:
https://docs.github.com/en/actions
https://github.com/expo/expo-github-action

@ztamizzen
Copy link

ztamizzen commented Mar 22, 2023

Is it possible to run expo/expo-github-action from inside a subfolder? Like <root>/my-react-native-project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment