name: Ensure Site Builds Cleanly
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install GraphicsMagick
        run: sudo apt install graphicsmagick
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: '14'
          cache: 'npm'
      - name: Restore node_modules cache
        uses: actions/cache@v2
        with:
          path: node_modules
          key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node_modules
      - name: Restore Asset Caches
        uses: actions/cache@v2
        with:
          key: if-cache
          path: |
            ./if-cache
            ./twitter-cache.json
      - run: npm i
      - run: npm test
      - run: npm run build
