Skip to content

chore: add Figma code connect (#424) #273

chore: add Figma code connect (#424)

chore: add Figma code connect (#424) #273

Workflow file for this run

name: Native UI Previews
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'packages/native-ui/**'
- 'apps/native-ui-storybook/**'
push:
branches:
- main
paths:
- 'packages/native-ui/**'
- 'apps/native-ui-storybook/**'
env:
CI: true
jobs:
build-for-android:
name: Build for Android
runs-on: macos-13-large
concurrency:
group: preview-android-${{ github.ref }}
cancel-in-progress: true
steps:
- name: πŸ— Setup repo
uses: pnpm/action-setup@v4
with:
version: 8
- name: πŸ— Checkout code
uses: actions/checkout@v3
- name: πŸ— Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: πŸ— Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17.0.10'
java-package: jdk
architecture: x64
- name: πŸ— Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: πŸ“¦ Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: πŸš€ Restore .env
if: github.event.action == 'synchronize' && !github.event_name != 'push'
working-directory: ./apps/native-ui-storybook
run: |
GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-android node ./scripts/getArtifacts.js
- name: πŸš€ Build Android APK Bundle
working-directory: ./apps/native-ui-storybook
run: pnpm run build:preview:android
- name: πŸ— Create/Read .env
run: touch ./apps/native-ui-storybook/.env.android && cat ./apps/native-ui-storybook/.env.android
- name: πŸš€ Load .env file
uses: xom9ikk/dotenv@v2
with:
path: ./apps/native-ui-storybook
mode: 'android'
- name: πŸš€ Upload new bundle to Appetize
uses: appetizeio/github-action-appetize@v1.0.1
id: appetizeio_github_action_appetize
if: github.event.action == 'opened' || github.event.action == 'reopened' || ${{ !env.ANDROID_API_KEY && github.action.event_name == 'pull_request' }}
with:
apiToken: ${{ secrets.APPETIZE_API_TOKEN }}
appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.apk
platform: 'android'
- name: πŸš€ Add output to .env
if: github.event.action == 'opened' || github.event.action == 'reopened' || !env.ANDROID_API_KEY
working-directory: ./apps/native-ui-storybook
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "ANDROID_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_ANDROID }}" >> .env.android
elif [ ${{steps.appetizeio_github_action_appetize.outputs.publicKey}} ]; then
echo "ANDROID_API_KEY=${{ steps.appetizeio_github_action_appetize.outputs.publicKey }}" >> .env.android
else
echo "No public key found"
fi
- name: πŸš€ Reload .env file
uses: xom9ikk/dotenv@v2
with:
path: ./apps/native-ui-storybook
mode: 'android'
- name: πŸš€ Save .env
uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request' && env.ANDROID_API_KEY
with:
name: ${{ github.event.pull_request.base.sha }}-env-android
path: ./apps/native-ui-storybook/.env.android
overwrite: true
- name: See env output
run: cat ./apps/native-ui-storybook/.env.android
- name: πŸš€ Upload updated bundle to Appetize
uses: appetizeio/github-action-appetize@v1.0.1
if: github.event.action != 'opened' && env.ANDROID_API_KEY
with:
apiToken: ${{ secrets.APPETIZE_API_TOKEN }}
publicKey: ${{ env.ANDROID_API_KEY }}
appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.apk
platform: 'android'
build-for-ios:
name: Build for iOS
runs-on: macos-13-xlarge
concurrency:
group: preview-ios-${{ github.ref }}
cancel-in-progress: true
steps:
- name: πŸ— Setup repo
uses: pnpm/action-setup@v4
with:
version: 8
- name: πŸ— Checkout code
uses: actions/checkout@v3
- name: πŸ— Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: πŸ— Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2.0'
- name: πŸ— Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: '9.2.0'
token: ${{ secrets.EXPO_TOKEN }}
- name: πŸ“¦ Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: πŸš€ Restore .env
if: github.event.action != 'opened' && github.event.action != 'reopened' && github.event_name == 'pull_request'
working-directory: ./apps/native-ui-storybook
run: |
GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-ios node ./scripts/getArtifacts.js
- name: πŸš€ Build iOS app
working-directory: ./apps/native-ui-storybook
run: pnpm run build:preview:ios
- name: πŸ— Create/Read .env
run: touch ./apps/native-ui-storybook/.env.ios && cat ./apps/native-ui-storybook/.env.ios
- name: πŸš€ Load .env file
uses: xom9ikk/dotenv@v2
with:
path: ./apps/native-ui-storybook
mode: 'ios'
- name: πŸš€ Upload new bundle to Appetize
uses: appetizeio/github-action-appetize@v1.0.1
id: appetizeio_github_action_appetize
if: github.event.action == 'opened' || github.event.action == 'reopened' || ${{ !env.IOS_API_KEY && github.action.event_name == 'pull_request' }}
with:
apiToken: ${{ secrets.APPETIZE_API_TOKEN }}
appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.tar.gz
platform: 'ios'
- name: πŸš€ Add output to .env
if: github.event.action == 'opened' || github.event.action == 'reopened' || !env.IOS_API_KEY
working-directory: ./apps/native-ui-storybook
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "IOS_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_IOS }}" >> .env.ios
elif [ ${{steps.appetizeio_github_action_appetize.outputs.publicKey}} ]; then
echo "IOS_API_KEY=${{ steps.appetizeio_github_action_appetize.outputs.publicKey }}" >> .env.ios
else
echo "No public key found"
fi
- name: πŸš€ Reload .env file
uses: xom9ikk/dotenv@v2
with:
path: ./apps/native-ui-storybook
mode: 'ios'
- name: See env output
run: cat ./apps/native-ui-storybook/.env.ios
- name: πŸš€ Save .env
uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request' && env.IOS_API_KEY
with:
name: ${{ github.event.pull_request.base.sha }}-env-ios
path: ./apps/native-ui-storybook/.env.ios
overwrite: true
- name: πŸš€ Upload updated bundle to Appetize
uses: appetizeio/github-action-appetize@v1.0.1
if: github.event.action != 'opened' && env.IOS_API_KEY
with:
apiToken: ${{ secrets.APPETIZE_API_TOKEN }}
publicKey: ${{ env.IOS_API_KEY }}
appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.tar.gz
platform: 'ios'
build-for-web:
name: Build for Web
runs-on: ubuntu-latest
needs:
- build-for-android
- build-for-ios
concurrency:
group: preview-web-${{ github.ref }}
cancel-in-progress: true
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: πŸ— Setup repo
uses: pnpm/action-setup@v4
with:
version: 8
- name: πŸ— Checkout code
uses: actions/checkout@v4
- name: πŸ— Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: πŸ— Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF##*/})"
id: extract_branch
- name: πŸ“¦ Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: πŸ“¦ Install Vercel CLI
run: pnpm install --global vercel@latest
- name: πŸš€ Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: πŸ— Restore Android .env
if: github.event_name != 'push'
working-directory: ./apps/native-ui-storybook
run: |
GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-android node ./scripts/getArtifacts.js
- name: πŸš€ Load .env.android file
if: github.event_name != 'push'
uses: xom9ikk/dotenv@v2
with:
path: ./apps/native-ui-storybook
mode: 'android'
- name: πŸš€ Create local .env and add Android key
working-directory: ./apps/native-ui-storybook
if: github.event_name != 'push'
run: |
echo "ANDROID_API_KEY=${{ env.ANDROID_API_KEY }}" >> .env
- name: πŸ— Restore iOS .env
if: github.event_name != 'push'
working-directory: ./apps/native-ui-storybook
run: |
GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-ios node ./scripts/getArtifacts.js
- name: πŸš€ Load .env.ios file
uses: xom9ikk/dotenv@v2
if: github.event_name != 'push'
with:
path: ./apps/native-ui-storybook
mode: 'ios'
- name: πŸš€ Create local .env and add iOS key
if: github.event_name != 'push'
working-directory: ./apps/native-ui-storybook
run: |
echo "IOS_API_KEY=${{ env.IOS_API_KEY }}" >> .env
- name: πŸš€ Create local production .env
if: github.event_name == 'push'
working-directory: ./apps/native-ui-storybook
run: |
echo "ANDROID_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_ANDROID }}" >> .env
echo "IOS_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_IOS }}" >> .env
- name: πŸš€ Pull Vercel Environment Information
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
vercel pull --yes --environment=preview --git-branch=${{ steps.extract_branch.outputs.branch }} --token=${{ secrets.VERCEL_TOKEN }}
else
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
fi
- name: πŸš€ Build Project Artifacts
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
vercel build --token=${{ secrets.VERCEL_TOKEN }}
else
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
fi
- name: πŸš€ Deploy Project Artifacts to Vercels
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --meta githubCommitRef=${{ github.head_ref }} --meta githubCommitSha=${{ github.sha }} > ./vercel-deploy.log
else
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} --meta githubCommitSha=${{ github.sha }} > ./vercel-deploy.log
fi
- name: πŸš€ Extract Deployment URL
if: github.event_name == 'pull_request'
id: extract_deployment_url
run: |
echo "deployment-url=$(cat ./vercel-deploy.log)" >> "$GITHUB_OUTPUT"
- name: πŸ’¬ Find Comment
uses: peter-evans/find-comment@v3
if: github.event_name == 'pull_request'
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Storybook Preview
- name: πŸ’¬ Create or update comment
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'pull_request'
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## πŸ–₯️ Native UI - Storybook Preview
Visit the Storybook preview URL to see the changes in action.
- Preview: [${{ steps.extract_deployment_url.outputs.deployment-url }}](${{ steps.extract_deployment_url.outputs.deployment-url }})
## πŸ“± Appetize Previews
You can view the apps using the link above and choosing the device from the top action bar. Alternatively you can use the direct links below.
- [Android](https://appetize.io/embed/${{ env.ANDROID_API_KEY }})
- [iOS](https://appetize.io/embed/${{ env.IOS_API_KEY }})
---
Last updated from commit ${{ github.sha }}
edit-mode: replace