diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f291011..964690b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: jobs: deploy: @@ -9,7 +13,7 @@ jobs: steps: - uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: '12.x' - name: Install netlify-cli run: npm install -g netlify-cli - name: Wait for Netlify @@ -26,7 +30,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: '12.x' - name: Install LHCI run: npm install -g @lhci/cli - name: Audit deploy preview @@ -56,4 +60,49 @@ jobs: uses: actions/upload-artifact@v1 with: name: lhci-results - path: ./.lighthouseci + path: './.lighthouseci' + + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + lfs: false + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + # https://github.com/actions/cache/blob/master/examples.md#node---yarn + # https://github.com/actions/cache/issues/60 + - name: Get yarn cache location + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - run: yarn install --no-ignore-optional --frozen-lockfile + - run: yarn build:preview + - uses: actions/upload-artifact@v1 + with: + name: public + path: './public' + + percy: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + needs: build + steps: + - uses: actions/download-artifact@v1 + with: + name: public + - uses: percy/snapshot-action@v0.1.0 + with: + build-directory: public + flags: --snapshot-files "**/index.html,notes/**/amp.html" + env: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}