name: 'CI/CD Pipeline' on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: '13.x' - name: Cache node modules uses: actions/cache@v1 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: ${{ runner.os }}-node- - run: npm ci - run: npm test build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: '13.x' - name: Cache node modules uses: actions/cache@v1 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: ${{ runner.os }}-node- - name: Cache Gatsby build output uses: actions/cache@v1 with: path: public key: ${{ runner.os }}-public - run: npm ci - run: npm run build env: GATSBY_GITHUB_TOKEN: ${{ secrets.GATSBY_GITHUB_TOKEN }} - uses: actions/upload-artifact@v1 with: name: public path: public deploy: needs: build if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/download-artifact@v1 with: name: public - run: ./scripts/deploy.sh