Skip to content

Instantly share code, notes, and snippets.

@nandorojo
Last active August 13, 2021 02:45
Show Gist options
  • Save nandorojo/edebe693458642cd7884a245eb4ee5c1 to your computer and use it in GitHub Desktop.
Save nandorojo/edebe693458642cd7884a245eb4ee5c1 to your computer and use it in GitHub Desktop.
Expo Release GH Actions
name: Build Binary App
on:
push:
branches: [binary-release, binary-beta]
workflow_dispatch:
inputs:
platform:
default: 'ios'
description: 'Could be "ios", "android", or "all"'
required: true
jobs:
environments:
name: Get App Environments
runs-on: ubuntu-latest
outputs:
environments: ${{ steps.get-environments.outputs.environments }}
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- id: get-environments
name: Get APP_ENV Matrix
uses: './.github/actions/select-environments'
build:
needs: environments
name: Build app on EAS
runs-on: ubuntu-latest
strategy:
matrix:
app-env: ${{fromJSON(needs.environments.outputs.environments)}}
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Start Deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.app-env }}
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', 'patches/**') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- uses: expo/expo-github-action@v6
with:
eas-version: latest
eas-cache: true
expo-cache: true
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: '.env.${{ matrix.app-env }}'
log-variables: true
- name: Log Env
run: echo "Owner -> ${{ steps.dotenv.outputs.EXPO_APP_OWNER }} / Slug -> ${{ steps.dotenv.outputs.EXPO_APP_SLUG }}"
- name: Start EAS Build
if: success()
working-directory: applications/speed
run: APP_ENV=${{ matrix.app-env }} eas build --platform ${{ github.event.inputs.platform || 'ios' }} --profile ${{ matrix.app-env }} --non-interactive --no-wait
- name: Update Deployment (build URL in previous step)
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
name: Over-the-air Update
on:
push:
branches: [ota-release, ota-beta]
workflow_dispatch:
jobs:
environments:
name: Get App Environments
runs-on: ubuntu-latest
outputs:
environments: ${{ steps.get-environments.outputs.environments }}
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', 'patches/**') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- id: get-environments
name: Get APP_ENV Matrix
uses: './.github/actions/select-environments'
ota:
needs: environments
name: OTA Update
runs-on: ubuntu-latest
strategy:
matrix:
app-env: ${{fromJSON(needs.environments.outputs.environments)}}
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Start Deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.app-env }}
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- uses: expo/expo-github-action@v6
with:
eas-version: latest
eas-cache: true
expo-cache: true
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
- name: Expo Config (No-op, keep for reference)
id: expo-config
# working-directory: applications/speed
run: echo '::set-output name=config::$(APP_ENV=${{ matrix.app-env }} expo config ./applications/speed --type public)'
# - name: Config Result
# run: echo "${{ steps.expo-config.outputs.config }}"
# - name: Config Result (to JSON)
# run: echo "${{ toJSON(steps.expo-config.outputs.config) }}"
# - name: Config Result (from + to JSON)
# run: echo "${{ fromJSON(toJSON(steps.expo-config.outputs.config)) }}"
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: '.env.${{ matrix.app-env }}'
log-variables: true
- name: Publish to Expo & create a QR code
uses: expo/expo-preview-action@v1
if: success()
env:
APP_ENV: ${{ matrix.app-env }}
with:
channel: ${{ matrix.app-env }}
project-root: applications/speed
scheme: ${{ steps.dotenv.outputs.EXPO_APP_SCHEME }}
id: preview
- name: Preview Deep Link
id: publish-url
# https://beatgigofficial.slack.com/archives/C020VQQ8WAE/p1628802677147000?thread_ts=1628799247.128900&cid=C020VQQ8WAE
run: echo "::set-output name=url::${{ steps.dotenv.outputs.EXPO_APP_SCHEME }}://expo-development-client/?url=${{ steps.preview.outputs.EXPO_MANIFEST_URL }}"
- name: Log Env
run: echo "Owner -> ${{ steps.dotenv.outputs.EXPO_APP_OWNER }} / Slug -> ${{ steps.dotenv.outputs.EXPO_APP_SLUG }}"
- name: Update Deployment Status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.preview.outputs.EXPO_MANIFEST_URL }}
- name: Comment on commit
uses: peter-evans/commit-comment@v1
with:
body: |
## Expo Preview Ready 🎹
Expo PR Preview ready for **${{ steps.dotenv.outputs.EXPO_APP_NAME }}**. [View it here.](${{ steps.publish-url.outputs.url }})
<a href="${{ steps.publish-url.outputs.url }}"><img src="${{ steps.preview.outputs.EXPO_QR_CODE_URL }}" height="512px" width="512px"></a>
Manifest URL: ${{ steps.preview.outputs.EXPO_MANIFEST_URL }}<br>
Preview URL: <a href="${{ steps.publish-url.outputs.url }}">${{ steps.publish-url.outputs.url }}</a>
${{ steps.preview.outputs.EXPO_NEW_BUILD_IS_REQUIRED_MESSAGE }}
name: Expo Preview
on:
push:
branches: [dev*, preview*]
paths:
- '**.ts'
- '**.tsx'
- '**.js'
- '**.json'
- '**.jsx'
- '**.patch'
- '**.lock'
- '.env.*'
- '.github/workflows/**'
workflow_dispatch:
jobs:
commit-preview:
name: Preview Expo Commit
runs-on: ubuntu-latest
env:
release-channel: commit-${{ github.sha }}
strategy:
matrix:
app-env: [dev, dev-sandbox]
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Start Deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.app-env }}
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- uses: expo/expo-github-action@v6
with:
eas-version: latest
eas-cache: true
expo-cache: true
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
- name: Dotenv
uses: falti/[email protected]
id: dotenv
with:
path: '.env.${{ matrix.app-env }}'
log-variables: true
- name: Publish to Expo & create a QR code
uses: expo/expo-preview-action@v1
if: success()
env:
APP_ENV: ${{ matrix.app-env }}
with:
channel: ${{ env.release-channel }}
project-root: applications/speed
scheme: ${{ steps.dotenv.outputs.EXPO_APP_SCHEME }}
id: preview
- name: Preview Deep Link
id: publish-url
# https://beatgigofficial.slack.com/archives/C020VQQ8WAE/p1628802677147000?thread_ts=1628799247.128900&cid=C020VQQ8WAE
run: echo "::set-output name=url::${{ steps.dotenv.outputs.EXPO_APP_SCHEME }}://expo-development-client/?url=${{ steps.preview.outputs.EXPO_MANIFEST_URL }}"
- name: Update Deployment Status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.preview.outputs.EXPO_MANIFEST_URL }}
- name: Comment on commit
uses: peter-evans/commit-comment@v1
if: success() && steps.publish-url.outputs.url
with:
body: |
# ${{ matrix.app-env }} Expo Preview 🎸
You can [view the published **${{ steps.dotenv.outputs.EXPO_APP_NAME }}** app](${{ steps.publish-url.outputs.url }}) now. 🥸
<a href="${{ steps.publish-url.outputs.url }}"><img src="${{ steps.preview.outputs.EXPO_QR_CODE_URL }}" height="512px" width="512px"></a>
Manifest URL: ${{ steps.preview.outputs.EXPO_MANIFEST_URL }}<br>
Preview URL: <a href="${{ steps.publish-url.outputs.url }}">${{ steps.publish-url.outputs.url }}</a>
${{ steps.preview.outputs.EXPO_NEW_BUILD_IS_REQUIRED_MESSAGE }}
pr-preview:
name: Preview Expo PR
runs-on: ubuntu-latest
strategy:
matrix:
app-env: [dev, dev-sandbox]
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- uses: 8BitJonny/[email protected]
id: PR
name: Check if we're in a PR
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Only return if PR is still open
filterOutClosed: true
- name: Start Deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.app-env }}
- name: Check If Comment Exists
uses: peter-evans/find-comment@v1
if: steps.PR.outputs.number != ''
id: comment-before-deploying
with:
issue-number: ${{ steps.PR.outputs.number }}
body-includes: Expo PR Preview
comment-author: github-actions[bot]
- name: Edit Comment to Mark Deploying
uses: peter-evans/create-or-update-comment@v1
if: ${{ success() && steps.PR.outputs.number && steps.comment-before-deploying.outputs.comment-id != '' }}
with:
comment-id: ${{ steps.existing-commment.outputs.comment-id }}
issue-number: ${{ steps.PR.outputs.number }}
edit-mode: append
reactions: +1, laugh, heart, hooray, rocket, eyes
body: <br/><br/>[deploying [${{ github.sha }}](https://github.com/${{ github.repository_owner }}/${{ github.repository }}/commits/${{ github.sha }})] ⏰
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Find yarn cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- uses: expo/expo-github-action@v6
with:
eas-version: latest
eas-cache: true
expo-cache: true
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: '.env.${{ matrix.app-env }}'
log-variables: true
- name: Publish to Expo & create a QR code
uses: expo/expo-preview-action@v1
if: success() && steps.PR.outputs.number
env:
APP_ENV: ${{ matrix.app-env }}
with:
channel: pr-${{ steps.PR.outputs.number }}
project-root: applications/speed
scheme: ${{ steps.dotenv.outputs.EXPO_APP_SCHEME }}
id: preview
- name: Preview Deep Link
id: publish-url
# https://beatgigofficial.slack.com/archives/C020VQQ8WAE/p1628802677147000?thread_ts=1628799247.128900&cid=C020VQQ8WAE
run: echo "::set-output name=url::${{ steps.dotenv.outputs.EXPO_APP_SCHEME }}://expo-development-client/?url=${{ steps.preview.outputs.EXPO_MANIFEST_URL }}"
- name: Update Deployment Status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.preview.outputs.EXPO_MANIFEST_URL }}
- name: Find Comment
uses: peter-evans/find-comment@v1
if: success() && steps.PR.outputs.number != ''
id: existing-comment
with:
issue-number: ${{ steps.PR.outputs.number }}
body-includes: Expo PR Preview
comment-author: github-actions[bot]
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v1
if: success() && steps.PR.outputs.number != ''
with:
comment-id: ${{ steps.existing-commment.outputs.comment-id }}
issue-number: ${{ steps.PR.outputs.number }}
edit-mode: replace
reactions: +1, laugh, heart, hooray, rocket, eyes
body: |
## PR Preview 🧑‍🎤
Expo PR Preview ready for **${{ steps.dotenv.outputs.EXPO_APP_NAME }}**. [View it here.](${{ steps.publish-url.outputs.url }})
<a href="${{ steps.publish-url.outputs.url }}"><img src="${{ steps.preview.outputs.EXPO_QR_CODE_URL }}" height="512px" width="512px"></a>
Manifest URL: ${{ steps.preview.outputs.EXPO_MANIFEST_URL }}<br>
Preview URL: <a href="${{ steps.publish-url.outputs.url }}">${{ steps.publish-url.outputs.url }}</a>
${{ steps.preview.outputs.EXPO_NEW_BUILD_IS_REQUIRED_MESSAGE }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment