From 07dffe772acdf631f8e38e6d984e038b2900609e Mon Sep 17 00:00:00 2001 From: bdovaz Date: Sun, 11 Jan 2026 20:37:25 +0100 Subject: [PATCH 1/2] feat: allow selection of platforms to build the custom flavor on --- .automation/build.py | 4 ++ docs/custom-flavors.md | 43 +++++++++++-------- flavors/custom-builder/action.yml | 5 +++ .../megalinter-custom-flavor-builder.yml | 1 + 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/.automation/build.py b/.automation/build.py index ed0ca72ffe3..63ebd0d26f1 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -3964,6 +3964,7 @@ def build_custom_flavor(dockerfile): work_dir = ( "/megalinter-builder" if os.path.isdir("/megalinter-builder") else REPO_HOME ) + platform = os.getenv('CUSTOM_FLAVOR_PLATFORM', 'linux/amd64') tag_id = os.getenv("CUSTOM_FLAVOR_BUILD_REPO", "megalinter-custom").replace( "/", "_" ) @@ -3971,6 +3972,8 @@ def build_custom_flavor(dockerfile): "docker", "buildx", "build", + "--platform", + platform, "-t", tag_id, "-f", @@ -3979,6 +3982,7 @@ def build_custom_flavor(dockerfile): "id=GITHUB_TOKEN", work_dir, ] + logging.info("Platforms to build on: " + platform) logging.info("Running command: " + " ".join(command)) process = subprocess.run( command, diff --git a/docs/custom-flavors.md b/docs/custom-flavors.md index 0b8c696218d..d3bee2787a1 100644 --- a/docs/custom-flavors.md +++ b/docs/custom-flavors.md @@ -18,7 +18,7 @@ You can easily generate your own MegaLinter custom flavor using the `mega-linter - Create a new GitHub public repository whose name starts with `megalinter-custom-flavor` (example: `megalinter-custom-flavor-npm-groovy-lint`), with default README checked. -![](assets/images/custom-flavor-new-repo.png) +![GitHub form to create a repository](assets/images/custom-flavor-new-repo.png) ### Clone your new repository locally @@ -35,7 +35,7 @@ npx mega-linter-runner@beta --custom-flavor-setup You can also send the list of linters as parameters, available from the logs of any official MegaLinter flavor (if you don't see it, make sure `FLAVOR_SUGGESTIONS: true` is defined in your `.mega-linter.yml` config file). -![](assets/images/custom-flavor-command.png) +![Example command to generate the custom flavor](assets/images/custom-flavor-command.png) ```bash npx mega-linter-runner@beta --custom-flavor-setup --custom-flavor-linters "PYTHON_BANDIT,PYTHON_BLACK,PYTHON_RUFF,REPOSITORY_TRIVY" @@ -45,23 +45,40 @@ npx mega-linter-runner@beta --custom-flavor-setup --custom-flavor-linters "PYTHO Select your custom flavor label and the linters you want to include. -![](assets/images/custom-flavor-linter-select.png) +![Selection of linters in the custom flavor](assets/images/custom-flavor-linter-select.png) ### Generated files The generator will create all necessary configuration files, GitHub Actions workflows, and documentation in your repository. Two workflows are generated: + - **megalinter-custom-flavor-builder.yml**: Builds and publishes your custom flavor Docker image - **check-new-megalinter-version.yml**: Automatically checks daily for new MegaLinter releases and creates matching releases in your repository -![](assets/images/custom-flavor-generated-files.png) +![Custom flavor generated files in VS Code](assets/images/custom-flavor-generated-files.png) + +### Optional: Generate the image for ARM + +> **Important:** Check the [linters you have selected](all_linters.md) in your flavor to see if they are compatible with `linux/arm64` platform. + +To build the image for ARM as well, edit **megalinter-custom-flavor-builder.yml** and change: + +```yml +platform: "linux/amd64" +``` + +To: + +```yml +platform: "linux/amd64,linux/arm64" +``` ### Commit and push your changes Commit and push the generated files to GitHub. -![](assets/images/custom-flavor-commit-push.png) +![Commit in VS Code](assets/images/custom-flavor-commit-push.png) ### Configure Personal Access Token (Required) @@ -106,17 +123,15 @@ Your custom flavor will be built and published automatically in two ways: - Push to any branch (except main) to build a `beta` tagged image - Manually run the `megalinter-custom-flavor-builder` workflow -![](assets/images/custom-flavor-release-1.png) +![Creating a GitHub release checks](assets/images/custom-flavor-release-1.png) -![](assets/images/custom-flavor-release-2.png) - -![](assets/images/custom-flavor-build-job.png) +![Creating a GitHub release form](assets/images/custom-flavor-release-2.png) ## Use a Custom Flavor Follow [MegaLinter installation guide](https://megalinter.io/latest/install-assisted/), and replace related elements in the workflow. -![](assets/images/custom-flavor-run.png) +![Running a custom flavor workflow](assets/images/custom-flavor-run.png) ### GitHub Action @@ -175,11 +190,3 @@ Your custom flavor automatically stays up to date with MegaLinter releases: 3. The builder workflow will automatically create your custom flavor using that MegaLinter version **Troubleshooting**: If automatic version checking isn't working, ensure you have configured the `PAT_TOKEN` secret as described in the setup instructions above. - - - - - - - - diff --git a/flavors/custom-builder/action.yml b/flavors/custom-builder/action.yml index b0d6692a7e3..a8feeddcee4 100644 --- a/flavors/custom-builder/action.yml +++ b/flavors/custom-builder/action.yml @@ -6,6 +6,10 @@ inputs: megalinter-custom-flavor-builder-tag: description: "Tag of the megalinter-custom-flavor-builder Docker image to use" required: true + platform: + description: "The platform(s) it will build on" + required: true + default: "linux/amd64" is-latest: description: "Is this the latest version of the custom flavor?" required: true @@ -32,6 +36,7 @@ runs: -v /var/run/docker.sock:/var/run/docker.sock:rw \ -v ${{ github.workspace }}:/github/workspace \ -e GITHUB_TOKEN=${{ env.GITHUB_TOKEN }} \ + -e CUSTOM_FLAVOR_PLATFORM=${{ inputs.platform }} \ -e CUSTOM_FLAVOR_BUILD_REPO=${{ env.CUSTOM_FLAVOR_BUILD_REPO }} \ -e CUSTOM_FLAVOR_BUILD_REPO_URL=${{ env.CUSTOM_FLAVOR_BUILD_REPO_URL }} \ -e CUSTOM_FLAVOR_BUILD_USER=${{ env.CUSTOM_FLAVOR_BUILD_USER }} \ diff --git a/mega-linter-runner/generators/mega-linter-custom-flavor/templates/megalinter-custom-flavor-builder.yml b/mega-linter-runner/generators/mega-linter-custom-flavor/templates/megalinter-custom-flavor-builder.yml index 9d6c6553f80..f524f2ee543 100644 --- a/mega-linter-runner/generators/mega-linter-custom-flavor/templates/megalinter-custom-flavor-builder.yml +++ b/mega-linter-runner/generators/mega-linter-custom-flavor/templates/megalinter-custom-flavor-builder.yml @@ -107,6 +107,7 @@ jobs: uses: oxsecurity/megalinter/flavors/custom-builder@main with: megalinter-custom-flavor-builder-tag: ${{ steps.determine-tag.outputs.tag }} + platform: "linux/amd64" is-latest: ${{ steps.determine-tag.outputs.is-latest }} upload-to-ghcr: "true" upload-to-dockerhub: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_PASSWORD != '' && 'true' || 'false' }} From b99227c53eff9ccad8b5d4fec0beeb92a76a6ea4 Mon Sep 17 00:00:00 2001 From: bdovaz <950602+bdovaz@users.noreply.github.com> Date: Sun, 11 Jan 2026 19:51:00 +0000 Subject: [PATCH 2/2] [MegaLinter] Apply linters fixes --- .automation/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/build.py b/.automation/build.py index 63ebd0d26f1..1c36d64b51b 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -3964,7 +3964,7 @@ def build_custom_flavor(dockerfile): work_dir = ( "/megalinter-builder" if os.path.isdir("/megalinter-builder") else REPO_HOME ) - platform = os.getenv('CUSTOM_FLAVOR_PLATFORM', 'linux/amd64') + platform = os.getenv("CUSTOM_FLAVOR_PLATFORM", "linux/amd64") tag_id = os.getenv("CUSTOM_FLAVOR_BUILD_REPO", "megalinter-custom").replace( "/", "_" )