chore: add Figma code connect #272
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |