Giter VIP home page Giter VIP logo

cfn-lint-action's Introduction

GitHub Action for CloudFormation Linter

This Action for CloudFormation Linter enables arbitrary actions for interacting with CloudFormation Linter to validate CloudFormation yaml/json templates against the CloudFormation spec and additional checks. Includes checking valid values for resource properties and best practices.

The Action's primary purpose is to set the CloudFormation Linter to the runner's $PATH so you can access the linter throughout the workflow, and use in a way that suits your application. There is a way to run a CloudFormation Linter command in this workflow though if you like.

On a pull request, once this GitHub Action is set-up, it may look something like this:

Output of Cloud Formation Linter

Usage

There are multiple ways to consume this GitHub Action.

The recommended approach would be to to use this action to add the CloudFormation Linter to the runners $PATH and run commands throughout the rest of the workflow. An example of that can be found below:

name: Lint CloudFormation Templates

on: [push]

jobs:
  cloudformation-linter:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Cloud Formation Linter with Latest Version
        uses: scottbrenner/cfn-lint-action@v2

      - name: Print the Cloud Formation Linter Version & run Linter.
        run: |
          cfn-lint --version
          cfn-lint -t ./template.yml

Within the run | section, you specify the required Cloud Formation Linter commands.

However, if you would rather run the CloudFormation Linter commands within this action. That is also possible. An example of that can be found below:

name: Lint CloudFormation Templates

on: [push]

jobs:
  cloudformation-linter:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Testing with CFN Lint Command
        uses: scottbrenner/cfn-lint-action@v2
        with:
          command: cfn-lint -t ./template.yml

Further, you can configure this action to download a specific version of the CloudFormation Linter, as well as the Python interpreter. See the table below for all the INPUTS this action can take.

Input Name Input Description Default Value Required?
version Version of CFN PyPi Package Latest Version of CFN PyPi Package false
python Python Version Defaults to python on Windows, and python3 otherwise. false
command Cloud Formation Linter Command to Run Afer Install N/A false

This GitHub Action does not directly output any values.

How to use the CloudFormation Linter?

See Cloud Formation Linter Usage for full usage details.

Upgrading from Version 1?

The main difference between Version 1 and Version 2 is the fact that Version 2 by default doesn't run any linting commands. The primary purpose of this action is now to provide the underlying CloudFormation Linter package and enable you to run your commands. To upgrade from Version 1 to Version 2, follow the steps below:

Step One

Change the action in your Workflow to be:

- name: Setup Cloud Formation Linter with Latest Version
  uses: scottbrenner/cfn-lint-action@v2

Step Two

Below the above include the following:

- name: Print the Cloud Formation Linter Version & run Linter.
  run: |
    cfn-lint --version
    cfn-lint -t ./**/*.yaml

This should give you the same experience as before.

Development

This is a JavaScript GitHub Action that relies on Node for third party packages, and can be developed locally or in GitHub Codespaces.

Running Locally

To get this working on your local machine, firstly make sure you have a working NodeJS runtime. It is also recommended to use Act to test & run actions locally. These instructions assume you have the GitHub CLI installed.

  1. Firstly, fork the repository by running:
gh repo fork ScottBrenner/cfn-lint-action
  1. Install dependencies
npm install
  1. To run the action locally run the following command
node index.js

GitHub Codespaces

If you’re in the Codespaces beta, you’ll see a “Code” button in the Code tab of this repository. The default codespace configuration automatically installs and configures all dependencies necessary for development of this project.

Contributing

Please see CONTRIBUTING.md for guidelines on how to contribute to this project.

License

Please see the LICENSE.

cfn-lint-action's People

Contributors

scottbrenner avatar dependabot[bot] avatar patmyron avatar nickliffen avatar softprops avatar jlrine2 avatar zmingxie avatar moltar avatar

Watchers

James Cloos 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.