From f48188f7adedfdab5b10d0efa7585d845bb6c253 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Sat, 26 Mar 2022 14:24:53 -0400 Subject: [PATCH 1/3] Update super-linter.yaml --- .github/workflows/super-linter.yaml | 30 ++++------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/super-linter.yaml b/.github/workflows/super-linter.yaml index 829e19f..c07a492 100644 --- a/.github/workflows/super-linter.yaml +++ b/.github/workflows/super-linter.yaml @@ -1,5 +1,5 @@ --- -# original template from: https://github.com/bretfisher/super-linter-example/blob/main/.github/workflows/super-linter.yaml +# original template from: https://github.com/bretfisher/super-linter-workflow/blob/main/.github/workflows/super-linter.yaml ########################### ########################### @@ -13,19 +13,8 @@ name: Lint all the codes # https://help.github.com/en/articles/workflow-syntax-for-github-actions # -############################# -# lint on push to release/main branches -# also lint on all pushes to PRs -############################# on: - # runs when PRs are merged, or pushes directly to these branches - # if you have multiple release branches, add them to push - push: - branches: - - main - # runs on pushed commits to any PR - pull_request: - # allow reuse of this workflow in other repos + workflow_call: inputs: devops-only: @@ -38,33 +27,22 @@ on: required: false type: string - permissions: - actions: none - checks: none # add custom pass/fail checks to the PR contents: read # git permissions to repo pull/push - deployments: none - issues: none # read/write to repo Issues - packages: none # read/write to repo Packages (ghcr, gems, npm) - pull-requests: none # read/write to repo PRs - repository-projects: none - security-events: none # read/write to repo Security tab API statuses: write # read/write to repo custom statuses and checks - jobs: super-lint: - # Name the Job + name: Super-Linter - # Set the agent to run on runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v3 with: - # Full git history is needed to get a proper list of changed files within `super-linter` + # Full git history is needed to get a proper list of changed files within super-linter fetch-depth: 0 ############################# From bbc3db188efafafb7a2f61e371329be2380519df Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Sat, 26 Mar 2022 11:35:15 -0700 Subject: [PATCH 2/3] more tweaks --- .github/linters/.markdown-lint.yml | 6 +++++ .../workflows/call-local-super-linter.yaml | 24 +++++++++++++++++++ README.md | 13 +++++----- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/workflows/call-local-super-linter.yaml diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..3d0e3a0 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,6 @@ +# MD013/line-length - Line length +MD013: + # Number of characters, default is 80 + line_length: 9999 + # check code blocks? + code_blocks: false \ No newline at end of file diff --git a/.github/workflows/call-local-super-linter.yaml b/.github/workflows/call-local-super-linter.yaml new file mode 100644 index 0000000..ccd8a6e --- /dev/null +++ b/.github/workflows/call-local-super-linter.yaml @@ -0,0 +1,24 @@ +--- +# THIS IS NOT A TEMPLATE. +# This is just for linting the gha-workflows repo itself. +# We call the reusable workflow from its file path. + +name: Lint + +on: + push: + branches: + - main + + pull_request: + +jobs: + call-super-linter: + + name: Call Super-Linter + + uses: ./.github/workflows/super-linter.yaml + + permissions: + contents: read # clone the repo to lint + statuses: write #read/write to repo custom statuses \ No newline at end of file diff --git a/README.md b/README.md index 9665118..6a36589 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,15 @@ The GitHub [Super-Linter](https://github.com/marketplace/actions/super-linter) p ## Features of this custom Super-Linter example -- All the features of [Super-Linter](https://github.com/marketplace/actions/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 +- All the features of [Super-Linter](https://github.com/marketplace/actions/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 -2. Add a workflow to all your other repositories that calls your linter workflow using GitHub's "Reusable Workflow" -3. Add something similar to this to those workflows: +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. ```yaml --- From f4ad2c1662ce385413548c70a8ad396edfcb15c8 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Sat, 26 Mar 2022 11:58:06 -0700 Subject: [PATCH 3/3] fixing lints --- .github/linters/.markdown-lint.yml | 1 + .github/linters/.yaml-lint.yml | 53 ++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/linters/.yaml-lint.yml diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml index 3d0e3a0..cb41d48 100644 --- a/.github/linters/.markdown-lint.yml +++ b/.github/linters/.markdown-lint.yml @@ -1,3 +1,4 @@ +--- # MD013/line-length - Line length MD013: # Number of characters, default is 80 diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 100644 index 0000000..030c37f --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1,53 @@ +--- +########################################### +# These are the rules used for # +# linting all the yaml files in the stack # +# NOTE: # +# You can disable line with: # +# # yamllint disable-line # +########################################### +rules: + braces: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + brackets: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + colons: + level: warning + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: warning + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: disable + comments-indentation: disable + document-end: disable + document-start: disable + empty-lines: + level: warning + max: 2 + max-start: 0 + max-end: 0 + hyphens: + level: warning + max-spaces-after: 1 + indentation: + level: warning + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable \ No newline at end of file diff --git a/README.md b/README.md index 6a36589..b3dbf7b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The GitHub [Super-Linter](https://github.com/marketplace/actions/super-linter) p ## 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. +2. Add a new workflow to all your other repositories and paste in this YAML to call the central-repos reusable workflow. ```yaml ---