Giter Site home page Giter Site logo

super-linter-workflow's Introduction

Super Linter Reusable Workflow Examples

Lint

The GitHub Super-Linter project is a fantastic way to lint all your file types with a single GitHub Actions Workflow. A great way to implement it everywhere is to use GHA's Reusable Workflows (see below).

My video walkthrough of this repository

Features of this custom Super-Linter example

  • All the features of Super-Linter in a Reusable Workflow.
  • Bonus: Optionally turn off non-DevOps linters (CSS, JS, HTML, etc.) when you want to ignore code (in my case it's to ignore sample code I stick in DevOps projects).
  • Bonus: I added Job steps to correctly determine which branch to diff files with (in the case of having multiple release branches).
  • Bonus: Lints only changed files on a PR, but lints all files on merge to main (or any release) branch.

How to reuse this example as a Reusable Workflow

  1. Fork this repository for you to customize your linters in a single location for your org/projects.
  2. Add a new workflow to all your other repositories and paste in this YAML to call the central-repos reusable workflow.
---
# template source: https://github.com/bretfisher/super-linter-workflow/blob/main/templates/call-super-linter.yaml
name: Lint Code Base

on:

  # run anytime a PR is merged to main or a direct push to main
  push:
    branches: [main]

  # run on any push to a PR branch
  pull_request:

# cancel any previously-started, yet still active runs of this workflow on the same branch
concurrency:
  group: ${{ github.ref }}-${{ github.workflow }}
  cancel-in-progress: true

jobs:
  call-super-linter:

    name: Call Super-Linter

    permissions:
      contents: read # clone the repo to lint
      statuses: write # read/write to repo custom statuses

    ### use Reusable Workflows to call my workflow remotely
    ### https://docs.github.com/en/actions/learn-github-actions/reusing-workflows
    ### you can also call workflows from inside the same repo via file path

    # FIXME: customize uri to point to your own reusable linter repository
    uses: bretfisher/super-linter-workflow/.github/workflows/reusable-super-linter.yaml@main

    ### Optional settings examples

    # with:
      ### For a DevOps-focused repository. Prevents some code-language linters from running
      ### defaults to false
      # devops-only: false

      ### A regex to exclude files from linting
      ### defaults to empty
      # filter-regex-exclude: html/.*

How to run Super-Linter locally

Option 1: Use nektos/act to run an existing GitHub Action workflow on your local repository clone.

Option 2: Use Docker to run the Super-Linter image directly.

Option 3: Pick the linter you want to run from Super-Linter, then install it locally to run manually. If you have a linter config, be sure to point the linter to .github/linters/*, and also realize that super-linter has default linter configs, that may change the linters behavior inside super-linter, with templates listed here.

This repository is part of my example DevOps repos on GitHub Actions

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ Join my container DevOps community ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

super-linter-workflow's People

Contributors

bretfisher avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.