Format Code: ensure code formatting guidelines are met #5979
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Format Code: ensure code formatting guidelines are met' | |
on: | |
workflow_dispatch: null | |
schedule: | |
- cron: '45 4 * * 1-5' | |
permissions: | |
contents: write | |
pull-requests: write | |
concurrency: | |
group: '${{ github.ref }}-${{ github.workflow }}' | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: MegaLinter | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 | |
with: | |
token: '${{ secrets.GITHUB_TOKEN }}' | |
fetch-depth: 0 | |
- name: Prepare Git options | |
run: bash ./scripts/git-setup.sh | |
- name: Run linter | |
id: ml | |
# You can override MegaLinter flavor used to have faster performances | |
# More info at https://megalinter.io/flavors/ | |
uses: oxsecurity/megalinter/flavors/terraform@ec124f7998718d79379a3c5b39f5359952baf21d #v8.4.2 | |
env: | |
# All available variables are described in documentation | |
# https://megalinter.io/configuration/#shared-variables | |
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY | |
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) | |
APPLY_FIXES_EVENT: all # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) | |
APPLY_FIXES_MODE: pull_request # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) | |
DISABLE_ERRORS: true | |
EMAIL_REPORTER: false | |
ENABLE_LINTERS: JSON_PRETTIER,YAML_PRETTIER,TERRAFORM_TERRAFORM_FMT,MARKDOWN_MARKDOWNLINT | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
VALIDATE_ALL_CODEBASE: true | |
YAML_PRETTIER_FILTER_REGEX_EXCLUDE: (.github/*) | |
MARKDOWN_MARKDOWNLINT_FILTER_REGEX_EXCLUDE: (terraform/modules/.*/.*.md) | |
REPORT_OUTPUT_FOLDER: none | |
- name: Commit and Create PR with Signed Commit if Changes are Found | |
uses: ministryofjustice/modernisation-platform-github-actions/signed-commit@41ce9117af6179f195ea00c3b7c06b3442d3e33c # v1.1.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
pr_title: "GitHub Actions Code Formatter workflow" | |
pr_body: "This pull request includes updates from the GitHub Actions Code Formatter workflow. Please review the changes and merge if everything looks good." |