natterstefan / nextjs-template

A practical starter template for Nextjs, which has Tailwind, Cypress, Docker, Storybook, Jest, ESLint, Prettier, and more built-in. 🚀
https://nextjs-template-app.vercel.app
MIT License
32 stars 4 forks source link

core: optimise GitHub Actions (e.g. caching and debugging) #68

Open natterstefan opened 2 years ago

natterstefan commented 2 years ago

Feature Request

Optimize and as a result, reduce GitHub Actions.

Examples and GitHub Actions

Triggers

on:
  # Triggers the workflow manually via the GitHub UI
  workflow_dispatch:
    inputs:
      debug_enabled:
        description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'     
        required: false
        default: false
  # Trigger the workflow when a pull_request's activity type is opened,
  # synchronize, or reopened.
  pull_request:
  # Trigger the workflow on push
  push:
    branches:
      - dev

      # use tmate in one of the jobs
      # Enable tmate debugging of manually-triggered workflows if the input
      # option was provided
      - name: Setup tmate session
        uses: mxschmitt/action-tmate@v3
        if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} 

Cypress Debugging

      # Test
      - name: Run Cypress Integration Tests
        run: npm run test:cypress:run
        working-directory: client

      # If the test fails, provide videos for debugging
      # TODO: conditionally enable `video: true` in cypress config
      - uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: cypress-videos
          path: cypress/videos/

Motivation

The changes should reduce the number of minutes the workflows consume.