build.yml 2.84 KB
Newer Older
Jeremy Tuloup's avatar
Jeremy Tuloup committed
1
2
3
4
name: Build

on:
  push:
5
    branches: [main]
Jeremy Tuloup's avatar
Jeremy Tuloup committed
6
7
8
  pull_request:
    branches: '*'

9
10
11
env:
  CACHE_EPOCH: 0

Jeremy Tuloup's avatar
Jeremy Tuloup committed
12
13
14
15
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
16
17
18
19
20
21
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install node
        uses: actions/setup-node@v2
        with:
          node-version: '14.x'
22
23
24
      - uses: actions/setup-python@v2
        with:
          python-version: '3.8'
25
26
      - name: Cache node modules
        uses: actions/cache@v2
27
        id: cache-node-modules
28
29
30
31
32
33
        with:
          path: 'node_modules/'
          key: |
            ${{ env.CACHE_EPOCH }}-${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}
      - name: Cache yarn packages
        uses: actions/cache@v2
34
35
        id: cache-yarn-packages
        if: steps.cache-node-modules.outputs.cache-hit != 'true'
36
37
38
39
40
41
        with:
          path: '.yarn-packages'
          key: |
            ${{ env.CACHE_EPOCH }}-yarn-packages-${{ hashFiles('yarn.lock') }}
          restore-keys: |
            ${{ env.CACHE_EPOCH }}-yarn-packages-
42
43
44
45
46
47
48
49
50
51
52
      - uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: |
            ${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
          restore-keys: |
            ${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-
      - name: Setup
        run: |
          pip install -U pip setuptools
          pip install -r requirements.txt
53
      - name: Install
Nicholas Bollweg's avatar
Nicholas Bollweg committed
54
        if: steps.cache-node-modules.outputs.cache-hit != 'true'
55
        run: |
Nicholas Bollweg's avatar
Nicholas Bollweg committed
56
          doit setup:js
57
58
      - name: Build
        run: |
59
          doit build
Nicholas Bollweg's avatar
Nicholas Bollweg committed
60
61
62
63
64
      - name: Upload (dist)
        uses: actions/upload-artifact@v2
        with:
          name: jupyterlite dist ${{ github.run_number }}
          path: ./dist
65
66
      - name: Lint
        run: |
67
          doit lint
68
69
      - name: Test
        run: |
70
          doit test
Jeremy Tuloup's avatar
Jeremy Tuloup committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

  deploy:
    needs: [build]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - uses: actions/download-artifact@v2
        with:
          name: jupyterlite dist ${{ github.run_number }}
          path: ./dist
      - name: Extract the app
        run: |
          tar -xvf ./dist/*.tgz
      - name: Deploy to Production
        id: prod
        run: |
          if [ "$REF" == 'refs/heads/main' ]
          then
              echo "::set-output name=vercel-args::--prod"
          else
              echo "::set-output name=vercel-args::"
          fi
        env:
          REF: ${{ github.ref }}
      - uses: amondnet/vercel-action@v20
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
          vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
          vercel-args: ${{ steps.prod.outputs.vercel-args }}
          working-directory: ./package