Scoped-actions
is a GitHub Action
to run commands on only changed files or changed workspaces of a Node project.
Pass any commands to be executed, when a command is one of the following, extra arguments are appended to make sure the commands only run on changed files or changed workspaces.
lint | eslint
: Run lint tool on changed and added filesprettier
: Run prettier on changed and added filestest | jest
: Run test on changed workspaces of a monorepo
Required: Changed and added files
files: ${{ steps.files.outputs.added_modified}}
This action uses jitterbit/get-changed-files to get changed and added files of a push or pull request.
- id: files
uses: jitterbit/get-changed-files@v1
with:
format: csv
token: ${{ github.token }}
Target glob pattern for ESLint, e.g: '**/*.{jsx,tsx,ts,js}'
Commands to be run in steps, e.g:
s0: 'npm install'
s1: 'npm run prettier-check'
s2: 'npm run lint'
s3: 'npm run test'
NOTE: Because extra arguments and options need to be appended to given commands, make sure your package.json
scripts don't end with a double dash --
.
on: [push, pull_request]
jobs:
run-test:
runs-on: ubuntu-latest
name: Run test, lint tool, code formatter on changed files and workspaces
steps:
- name: Checkout
uses: actions/checkout@v2
- id: files
uses: jitterbit/get-changed-files@v1
with:
format: csv
token: ${{ github.token }}
- name: Run scoped actions
uses: DukeManh/scoped-actions@v1
with:
files: ${{ steps.files.outputs.added_modified}}
eslintTarget: '**/*.{jsx,tsx,ts,js}'
s0: 'npm install'
s1: 'npm run prettier-check'
s2: 'npm run lint'
s3: 'npm run test'