|
| 1 | +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: Node.js CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ master, dev ] |
| 9 | + |
| 10 | + pull_request: |
| 11 | + branches: [ master, dev ] |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: Build & Test |
| 16 | + |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + os: [ ubuntu-latest ] |
| 22 | + node-version: [ 12.x, 14.x ] |
| 23 | + fail-fast: true |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v2 |
| 28 | + |
| 29 | + - name: Use Node.js ${{ matrix.node-version }} |
| 30 | + uses: actions/setup-node@v2-beta |
| 31 | + with: |
| 32 | + node-version: ${{ matrix.node-version }} |
| 33 | + |
| 34 | + - name: Cache node_modules |
| 35 | + id: cache-modules |
| 36 | + uses: actions/cache@v2 |
| 37 | + with: |
| 38 | + path: node_modules |
| 39 | + key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('yarn.lock') }} |
| 40 | + |
| 41 | + - name: Install Dependencies |
| 42 | + if: steps.cache-modules.outputs.cache-hit != 'true' |
| 43 | + run: yarn install |
| 44 | + |
| 45 | + - name: Lint |
| 46 | + run: yarn lint |
| 47 | + |
| 48 | + - name: Test |
| 49 | + run: yarn test |
| 50 | + |
| 51 | + publish: |
| 52 | + name: Publish |
| 53 | + |
| 54 | + needs: test |
| 55 | + |
| 56 | + runs-on: ${{ matrix.os }} |
| 57 | + |
| 58 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 59 | + |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + os: [ ubuntu-latest ] |
| 63 | + fail-fast: true |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v2 |
| 68 | + |
| 69 | + - name: Cache node_modules |
| 70 | + id: cache-modules |
| 71 | + uses: actions/cache@v2 |
| 72 | + with: |
| 73 | + path: node_modules |
| 74 | + key: 12.x-${{ runner.OS }}-build-${{ hashFiles('yarn.lock') }} |
| 75 | + |
| 76 | + - name: Install Dependencies |
| 77 | + if: steps.cache-modules.outputs.cache-hit != 'true' |
| 78 | + run: yarn install |
| 79 | + |
| 80 | + - name: Test |
| 81 | + run: yarn test |
| 82 | + |
| 83 | + - name: Upload Coverage to Codecov |
| 84 | + uses: codecov/codecov-action@v1 |
| 85 | + with: |
| 86 | + directory: ./coverage |
| 87 | + |
| 88 | + - name: Publish to NPM |
| 89 | + uses: mikeal/merge-release@master |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 93 | + |
| 94 | + docs: |
| 95 | + name: Documentation |
| 96 | + |
| 97 | + needs: test |
| 98 | + |
| 99 | + runs-on: ${{ matrix.os }} |
| 100 | + |
| 101 | + if: github.ref == 'refs/heads/master' |
| 102 | + |
| 103 | + strategy: |
| 104 | + matrix: |
| 105 | + os: [ ubuntu-latest ] |
| 106 | + node-version: [ 12.x ] |
| 107 | + fail-fast: true |
| 108 | + |
| 109 | + steps: |
| 110 | + - name: Checkout |
| 111 | + uses: actions/checkout@v2 |
| 112 | + |
| 113 | + - name: Use Node.js ${{ matrix.node-version }} |
| 114 | + uses: actions/setup-node@v2-beta |
| 115 | + with: |
| 116 | + node-version: ${{ matrix.node-version }} |
| 117 | + |
| 118 | + - name: Cache node_modules |
| 119 | + id: cache-modules-docs |
| 120 | + uses: actions/cache@v2 |
| 121 | + with: |
| 122 | + path: ./docs/node_modules |
| 123 | + key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('yarn.lock') }} |
| 124 | + |
| 125 | + - name: Install Dependencies |
| 126 | + if: steps.cache.outputs.cache-hit != 'true' |
| 127 | + working-directory: ./docs |
| 128 | + run: yarn install |
| 129 | + |
| 130 | + - name: Generate |
| 131 | + working-directory: ./docs |
| 132 | + run: yarn generate |
| 133 | + |
| 134 | + - name: Deploy |
| 135 | + uses: peaceiris/actions-gh-pages@v3 |
| 136 | + with: |
| 137 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + publish_dir: ./docs/dist |
0 commit comments