xref: /expo/.github/workflows/web.yml (revision 0fd9a914)
1name: Publish Expo Web
2on:
3  pull_request:
4    paths:
5      - .github/workflows/web.yml
6      - yarn.lock
7      - apps/**
8      - packages/**
9
10jobs:
11  build:
12    runs-on: ubuntu-latest
13    steps:
14      - uses: actions/checkout@v2
15        with:
16          submodules: true
17      - name: Get cache key of git lfs files
18        id: git-lfs
19        run: echo "::set-output name=sha256::$(git lfs ls-files | openssl dgst -sha256)"
20      - uses: actions/cache@v2
21        with:
22          path: .git/lfs
23          key: ${{ steps.git-lfs.outputs.sha256 }}
24      - run: git lfs pull
25      - run: yarn global add expo-cli
26      - name: Cache Node.js modules
27        uses: actions/cache@v1
28        with:
29          path: ${{ github.workspace }}/node_modules
30          key: ${{ runner.OS }}-node_modules-${{ hashFiles('yarn.lock') }}
31      #  Setup Expo CLI action
32      # - name: Setup Expo
33      #   uses: expo/expo-github-action@v5
34      #   with:
35      #     expo-version: 3.x
36      #     expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
37      #     expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
38      #     expo-cache: true
39
40      - run: yarn --frozen-lockfile
41
42      # - name: Publish Expo app
43      #   working-directory: ./apps/native-component-list
44      #   run: expo publish --release-channel=pr-${{ github.event.number }}
45      # # Get Expo link for the comment
46      # - name: Get expo link
47      #   id: expo
48      #   run: echo "::set-output name=path::@community/native-component-list?release-channel=pr-${{ github.event.number }}"
49      # Build the Expo website
50      - name: Build Website
51        working-directory: ./apps/native-component-list
52        run: yarn build:web
53      # Deploy Expo web to now
54      - name: Publish Website
55        working-directory: ./apps/native-component-list
56        env:
57          ZEIT_TOKEN: ${{ secrets.ZEIT_TOKEN }}
58          BUILD_ID: ${{ github.sha }}
59        run: npx now deploy web-build --env NODE_ENV=production --confirm --public --no-clipboard --token=${ZEIT_TOKEN} > deploy-url.txt
60      # Save variable
61      - name: Set deploy url to env variable
62        run: echo "::set-env name=ZEIT_DEPLOY::$(cat deploy-url.txt)"
63      # Alias the now deployment URL
64      - name: Alias with PR number
65        working-directory: ./apps/native-component-list
66        env:
67          ZEIT_TOKEN: ${{ secrets.ZEIT_TOKEN }}
68          SITE_ALIAS: expo-web-${{ github.event.number }}.now.sh
69        run: npx now alias --token=${ZEIT_TOKEN} `cat deploy-url.txt` $SITE_ALIAS
70      # Send comment to the thread
71      - name: Add comment with deploy url
72        uses: unsplash/comment-on-pr@master
73        env:
74          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75        with:
76          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>
77          # 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.io/${{ 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>
78