xref: /expo/.github/workflows/web.yml (revision eebf9368)
1name: Publish Expo Web
2on:
3  workflow_dispatch: {}
4  # pull_request:
5  #   paths:
6  #     - .github/workflows/web.yml
7  #     - yarn.lock
8  #     - apps/**
9  #     - packages/**
10
11concurrency:
12  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
13  cancel-in-progress: true
14
15jobs:
16  build:
17    runs-on: ubuntu-latest
18    steps:
19      - uses: actions/checkout@v2
20        with:
21          submodules: true
22      - name: Get cache key of git lfs files
23        id: git-lfs
24        run: echo "::set-output name=sha256::$(git lfs ls-files | openssl dgst -sha256)"
25      - uses: actions/cache@v2
26        with:
27          path: .git/lfs
28          key: ${{ steps.git-lfs.outputs.sha256 }}
29      - run: git lfs pull
30      - uses: actions/setup-node@v2
31        with:
32          node-version: '14.17'
33      - run: yarn global add expo-cli@3
34      - name: Cache Node.js modules
35        uses: actions/cache@v2
36        with:
37          path: ${{ github.workspace }}/node_modules
38          key: ${{ runner.OS }}-node_modules-${{ hashFiles('yarn.lock') }}
39      #  Setup Expo CLI action
40      # - name: Setup Expo
41      #   uses: expo/expo-github-action@v5
42      #   with:
43      #     expo-version: 3.x
44      #     expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
45      #     expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
46      #     expo-cache: true
47
48      - run: yarn --frozen-lockfile
49
50      # - name: Publish Expo app
51      #   working-directory: ./apps/native-component-list
52      #   run: expo publish --release-channel=pr-${{ github.event.number }}
53      # # Get Expo link for the comment
54      # - name: Get expo link
55      #   id: expo
56      #   run: echo "::set-output name=path::@community/native-component-list?release-channel=pr-${{ github.event.number }}"
57      # Build the Expo website
58      - name: Build Website
59        working-directory: ./apps/native-component-list
60        run: yarn build:web
61      # Deploy Expo web to now
62      - name: Publish Website
63        if: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
64        working-directory: ./apps/native-component-list
65        env:
66          ZEIT_TOKEN: ${{ secrets.ZEIT_TOKEN }}
67          BUILD_ID: ${{ github.sha }}
68        run: npx now deploy web-build --env NODE_ENV=production --confirm --public --no-clipboard --token=${ZEIT_TOKEN} > deploy-url.txt
69      # Save variable
70      - name: Set deploy url to env variable
71        if: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
72        run: echo "ZEIT_DEPLOY=$(cat deploy-url.txt)" >> $GITHUB_ENV
73      # Alias the now deployment URL
74      - name: Alias with PR number
75        if: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
76        working-directory: ./apps/native-component-list
77        env:
78          ZEIT_TOKEN: ${{ secrets.ZEIT_TOKEN }}
79          SITE_ALIAS: expo-web-${{ github.event.number }}.now.sh
80        run: npx now alias --token=${ZEIT_TOKEN} `cat deploy-url.txt` $SITE_ALIAS
81      # Send comment to the thread
82      - name: Add comment with deploy url
83        if: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
84        uses: unsplash/comment-on-pr@master
85        env:
86          GITHUB_TOKEN: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
87        with:
88          msg: Native Component List for this branch is ready<br><a aria-label="Try the web preview of this PR" href="https://expo-web-${{ github.event.number }}.now.sh/"><img longdesc="Try the web preview of this PR" src="https://img.shields.io/badge/Web-Run_Now-4630EB.svg?style=for-the-badge&logo=GOOGLE-CHROME&labelColor=000&logoColor=fff" target="_blank" /></a>
89          # msg: Native Component List for this branch is ready<br><a aria-label="Try the web preview of this PR" href="https://expo-web-${{ github.event.number }}.now.sh/"><img longdesc="Try the web preview of this PR" src="https://img.shields.io/badge/Web-Run_Now-4630EB.svg?style=for-the-badge&logo=GOOGLE-CHROME&labelColor=000&logoColor=fff" target="_blank" /></a><br><a aria-label="Try the native preview of this PR" href="https://expo.dev/${{ steps.expo.outputs.path }}"><img longdesc="Try the native preview of this PR" src="https://img.shields.io/badge/Native-Run_Now-4630EB.svg?style=for-the-badge&logo=EXPO&labelColor=000&logoColor=fff" target="_blank" /></a><br><br><a href="https://exp.host/${{ steps.expo.outputs.path }}"><img src="https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=exp://exp.host/${{ steps.expo.outputs.path }}" height="200px" width="200px"></a>
90