build.yml 3.03 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
env:
10
  CACHE_EPOCH: 1
11

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
      - name: Setup pip (pip)
        run: |
          pip install -U pip setuptools wheel
45
46
47
48
      - uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: |
Nicholas Bollweg's avatar
Nicholas Bollweg committed
49
            ${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }}
50
51
          restore-keys: |
            ${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-
52
      - name: Setup pip (dependencies)
53
        run: |
Nicholas Bollweg's avatar
Nicholas Bollweg committed
54
          pip install -r requirements-docs.txt
55
      - name: Install
Nicholas Bollweg's avatar
Nicholas Bollweg committed
56
        if: steps.cache-node-modules.outputs.cache-hit != 'true'
57
        run: |
Nicholas Bollweg's avatar
Nicholas Bollweg committed
58
          doit setup:js
59
60
      - name: Build
        run: |
61
          doit build
Nicholas Bollweg's avatar
Nicholas Bollweg committed
62
63
64
65
66
      - name: Upload (dist)
        uses: actions/upload-artifact@v2
        with:
          name: jupyterlite dist ${{ github.run_number }}
          path: ./dist
67
68
      - name: Lint
        run: |
69
          doit lint
70
71
      - name: Test
        run: |
72
          doit test
Nicholas Bollweg's avatar
Nicholas Bollweg committed
73
74
75
76
77
78
      - name: Docs
        run: |
          doit docs
      - name: Check Built Artifacts
        run: |
          doit check
Jeremy Tuloup's avatar
Jeremy Tuloup committed
79
80
81
82
83

  deploy:
    needs: [build]
    runs-on: ubuntu-latest
    steps:
84
85
      - name: Checkout
        uses: actions/checkout@v2
Jeremy Tuloup's avatar
Jeremy Tuloup committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
      - 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