Skip to content

Commit

Permalink
Drone CI generator support + Drone CI docs improvement (#2195)
Browse files Browse the repository at this point in the history
* Add Drone CI template

* Initial drone CI generator

* Add docs about trigger rules for Drone CI

* Add changelog entry

* Make the Drone CI doc more readable
  • Loading branch information
NebulaOnion authored Jan 1, 2023
1 parent b359f69 commit 5399d4e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- [eslint](https://eslint.org) from 8.30.0 to **8.31.0** on 2022-12-31
- [checkstyle](https://checkstyle.sourceforge.io) from 10.5.0 to **10.6.0** on 2023-01-01
<!-- linter-versions-end -->
- Drone CI enhancements
- Config generator tool now supports Drone CI
- Added information about how to change trigger rules for Drone CI workflow
- New MegaLinter plugin: [linkcheck](https://github.com/shiranr/linkcheck): Plugin to check and validate Markdown links.

## [v6.17.0] - 2022-12-27
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,32 @@ steps:

This uses the [Drone CI docker runner](https://docs.drone.io/pipeline/docker/overview/), so it's needed to install and configure it beforehand on your Drone CI server.

#### (Optional) Adjusting trigger rules

The Drone CI workflow should trigger automatically for every scenario (push, pull request, sync...) however, you can *optionally* change this behavior by changing the trigger. For example:

```yaml
kind: pipeline
type: docker
name: MegaLinter
workspace:
path: /tmp/lint
steps:
- name: megalinter
image: oxsecurity/megalinter:v6
environment:
DEFAULT_WORKSPACE: /tmp/lint
trigger:
event:
- push
```

The workflow above should only trigger on push, not on any other situation. For more information about how to configure Drone CI trigger rules, [click here](https://docs.drone.io/pipeline/triggers/).

### Docker container

You can also run megalinter with its Docker container, just execute this command:
Expand Down
16 changes: 15 additions & 1 deletion mega-linter-runner/generators/mega-linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ When you don't know what option to select, please use default values`
default: "gitHubActions",
choices: [
{ name: "GitHub Actions", value: "gitHubActions" },
{ name: "Drone CI", value: "droneCI" },
{ name: "Jenkins", value: "jenkins" },
{ name: "GitLab CI", value: "gitLabCI" },
{ name: "Azure Pipelines", value: "azure" },
Expand Down Expand Up @@ -138,6 +139,7 @@ When you don't know what option to select, please use default values`
writing() {
// Generate workflow config
this._generateGitHubAction();
this._generateDroneCI();
this._generateJenkinsfile();
this._generateGitLabCi();
this._generateAzurePipelines();
Expand Down Expand Up @@ -231,7 +233,19 @@ When you don't know what option to select, please use default values`
}
);
}

_generateDroneCI() {
if (this.props.ci !== "droneCI") {
return;
}
this.fs.copyTpl(
this.templatePath(".drone.yml"),
this.destinationPath(".drone.yml"),
{
APPLY_FIXES: this.props.applyFixes === true ? "all" : "none",
DEFAULT_BRANCH: this.props.defaultBranch,
}
);
}
_generateJenkinsfile() {
if (this.props.ci !== "jenkins") {
return;
Expand Down
15 changes: 15 additions & 0 deletions mega-linter-runner/generators/mega-linter/templates/.drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: pipeline
type: docker
name: MegaLinter


workspace:
path: /tmp/lint

steps:


- name: megalinter
image: oxsecurity/megalinter:v6
environment:
DEFAULT_WORKSPACE: /tmp/lint

0 comments on commit 5399d4e

Please sign in to comment.