Skip to content

Instantly share code, notes, and snippets.

@dib258
Created February 3, 2022 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dib258/8c975019b174e37cb1fd159039e77f43 to your computer and use it in GitHub Desktop.
Save dib258/8c975019b174e37cb1fd159039e77f43 to your computer and use it in GitHub Desktop.
Github Action file that runs Eslint linter on the project
# This is a basic workflow to help you get started with Actions
name: ESLint
# Controls when the workflow will run
on:
push
# Triggers the workflow on push or pull request events but only for the main branch
# on: [push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "run-linters"
run-linters:
name: Run linters
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out Git repository
uses: actions/checkout@v2
# to work with pull request
# with:
# ref: ${{ github.head_ref }}
# Install packages
- name: Install modules
run: yarn
# Run Eslint and Fix
- name: Run ESLint
run: ./node_modules/.bin/eslint . --ext .js,.ts,.vue --fix
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix eslint styling
branch: ${{ steps.extract_branch.outputs.branch }}
commit_options: '--no-verify'
commit_user_name: GitHub Actions Bot # defaults to "GitHub Actions"
commit_user_email: github-actions-bot@chillpills.io # defaults to "actions@github.com"
commit_author: GitHub Actions Bot <github-actions-bot@chillpills.io> # defaults to author of the commit that triggered the run
# Optional. Disable dirty check and always try to create a commit and push
skip_dirty_check: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment