Skip to content

Instantly share code, notes, and snippets.

@NoriSte
Created February 14, 2025 14:14
Show Gist options
  • Save NoriSte/37c4dba4d3928953c854bc9b0febfda0 to your computer and use it in GitHub Desktop.
Save NoriSte/37c4dba4d3928953c854bc9b0febfda0 to your computer and use it in GitHub Desktop.
name: Update React Native Storybook
on:
push:
branches:
- main
pull_request:
types:
- ready_for_review
branches-ignore:
- "dependabot-*"
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update:
name: EAS Update
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check for EXPO_TOKEN
run: |
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn
- name: Install EAS CLI
run: npm install -g eas-cli
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn build:rn
- name: Create preview
working-directory: ./support/rn-expo
run: |
# Extract the needed into from the eas CLI's stdout, which is something like# Extracts the needed into from the eas CLI's stdout, which is something like
# Branch main
# Runtime version 1.0.0
# Platform android, ios
# Update group ID e28f5966-6604-49ee-bd5b-dd112464a2b2
# Android update ID 7a5c179f-edc4-4fb7-879c-c87f161e6c01
# iOS update ID f14148cd-6d69-41ae-b5db-da17a7b172cc
# Message (update)
# Commit 4a07a0b14ee0a957b799589d87b8b2357ec66bbd*
# EAS Dashboard https://expo.dev/accounts/stefano.magni/projects/StickerSmash/updates/e28f5966-6604-49ee-bd5b-dd112464a2b2
set -x # Enable debug mode to print each command before executing
EAS_LOG=$(EXPO_TOKEN=${{ secrets.EXPO_TOKEN }} yarn distribute 2>&1)
echo "$EAS_LOG" # Print the full log for debugging
DASHBOARD_URL=$(echo "$EAS_LOG" | grep "EAS Dashboard" | awk '{print $NF}')
GROUP_ID=$(echo "$EAS_LOG" | grep "Update group ID" | awk '{print $NF}')
echo "DASHBOARD_URL=$DASHBOARD_URL" >> $GITHUB_ENV
echo "GROUP_ID=$GROUP_ID" >> $GITHUB_ENV
- name: Post Expo Preview Comment in PR
uses: mshick/add-pr-comment@v2
with:
message: |
React Native Storybook has been published for testing ๐Ÿš€
๐Ÿ”— [EAS Dashboard Link](${{ env.DASHBOARD_URL }})
Steps:
1. Download Expo Go ([Android](https://play.google.com/store/apps/details?id=host.exp.exponent), [iOS](https://apps.apple.com/us/app/expo-go/id982107779))
2. Open it and scan the following QR
<img src="https://qr.expo.dev/eas-update?projectId=7526cb51-fbd8-4185-b8ec-c824b6d5e573&groupId=${{ env.GROUP_ID }}" alt="Expo Go QR Code" width="150"/>
allow-repeats: true
- name: On Failure
if: failure()
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: failure_comment
mode: recreate
message: |
React Native Storybook deployment failed :scream:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment