Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo Build for PRs #246

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ jobs:
eas update --branch="${{ github.event.deployment_status.environment_url }}" --non-interactive --auto
echo "${{ env.BACKEND_SERVER_URL }} and ${{ github.event.deployment_status.environment_url }}"
env:
# TODO: Is SENTRY_PROJECT_NAME and SENTRY_DSN needed here?
EXPO_PUBLIC_BACKEND_SERVER_URL: "${{ github.event.deployment_status.environment_url }}"
EXPO_PUBLIC_ROLLBAR_ACCESS_TOKEN: "1a19e5da05b2435b802d5a81aba2bbd7"
21 changes: 21 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/expo-build.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I've merged a couple ideas from in-progress work from @oudeismetis with the expo-build.yml config from @lakardion — testing this on a project now and will adjust as needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome! warms my heart 🙏

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ on:
default: false
type: "boolean"
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: jwalton/gh-find-current-pr@v1
id: findPr
- name: Set name for PR
if: success() && steps.findPr.outputs.number
run: echo "PR=pr-${PR}" >> $GITHUB_ENV
env:
PR: {{ "${{ steps.findPr.outputs.pr }}" }}
outputs:
PR: {{ "${{ env.PR }}" }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a deployment_status event, we don't need to do this as the event itself tells us the PR, URL, etc.
But we might still need this for workflow_dispatch events.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still use jwalton/gh-find-current-pr in a bunch of places we don't need to. I have an example on a project or two somewhere showing how to get the value from the deployment event.


build:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -64,3 +77,11 @@ jobs:
CLEAR_CACHE_FLAG="--clear-cache"
fi
eas build --profile {{ "${{ github.event.inputs.profile }}" }} --platform {{ "${{ github.event.inputs.platform }}" }} --non-interactive $CLEAR_CACHE_FLAG

- name: 🚀 Publish PR Preview
run: cd mobile && eas update --branch={{ "${{ needs.setup.outputs.PR }}" }} --non-interactive --auto
env:
BACKEND_SERVER_URL: {{ "${{ github.event.deployment_status.environment_url }}" }}
ROLLBAR_ACCESS_TOKEN: ""
SENTRY_PROJECT_NAME: ""
SENTRY_DSN: ""
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ jobs:

- name: 🚀 Publish preview
run: cd mobile && eas update --branch=production --non-interactive --auto
env:
# Since expo update replaces code OTA these variables should match the environment variables in eas.json
EXPO_PUBLIC_BACKEND_SERVER_URL: ""
EXPO_PUBLIC_ROLLBAR_ACCESS_TOKEN: ""
SENTRY_PROJECT_NAME: ""
SENTRY_DSN": ""
13 changes: 7 additions & 6 deletions {{cookiecutter.project_slug}}/.github/workflows/expo-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
setup:
runs-on: ubuntu-latest
outputs:
BUILD_MOBILE_APP: {{ "${{ steps.checkdiff.outputs.BUILD_MOBILE_APP }}" }}
BUILD_MOBILE_APP:
{{ "${{ steps.checkdiff.outputs.BUILD_MOBILE_APP }}" }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -64,14 +65,14 @@ jobs:

- name: 🚀 Build app
run: cd mobile && eas build --platform all --profile staging --non-interactive
env:
SENTRY_PROJECT_NAME: "<REPLACE_WTIH_SENTRY_PROJECT_NAME>"
env:
SENTRY_PROJECT_NAME: "<REPLACE_WITH_SENTRY_PROJECT_NAME>"

- name: 🚀 Publish Staging Preview
run: cd mobile && eas update --branch=staging --non-interactive --auto
env:
# Since expo update replaces code OTA these variables should match the staging variables in eas.json
# Since expo update replaces code OTA these variables should match the staging variables in eas.json
EXPO_PUBLIC_BACKEND_SERVER_URL: ""
EXPO_PUBLIC_ROLLBAR_ACCESS_TOKEN: ""


SENTRY_PROJECT_NAME: ""
SENTRY_DSN: ""
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/expo-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ jobs:
env:
EXPO_PUBLIC_BACKEND_SERVER_URL: {{ "${{ github.event.deployment_status.environment_url }}" }}
EXPO_PUBLIC_ROLLBAR_ACCESS_TOKEN: ""
SENTRY_PROJECT_NAME: ""
SENTRY_DSN: ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Sentry vars are needed, otherwise they will be blank in the eas update JS bundle and cause the app to crash on startup: #332

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
with:
expo-version: latest
eas-version: latest
token: {{ "${{ secrets.EXPO_TOKEN }}" }}
token: {{ "${{ secrets.EXPO_TOKEN }}" }}

- name: 📦 Install dependencies
working-directory: ./mobile
run: npm install

- name: 🚀 Build app
run: cd mobile && eas build --platform android --profile production --non-interactive --auto-submit
env:
SENTRY_PROJECT_NAME: "<REPLACE_WTIH_SENTRY_PROJECT_NAME>"
env:
SENTRY_PROJECT_NAME: "<REPLACE_WITH_SENTRY_PROJECT_NAME>"
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
with:
expo-version: latest
eas-version: latest
token: {{ "${{ secrets.EXPO_TOKEN }}" }}
token: {{ "${{ secrets.EXPO_TOKEN }}" }}

- name: 📦 Install dependencies
working-directory: ./mobile
run: npm install

- name: 🚀 Build app
run: cd mobile && eas build --platform ios --profile production --non-interactive --auto-submit
env:
SENTRY_PROJECT_NAME: "<REPLACE_WTIH_SENTRY_PROJECT_NAME>"
env:
SENTRY_PROJECT_NAME: "<REPLACE_WITH_SENTRY_PROJECT_NAME>"
Loading