Skip to content

Unable to run within GitHub action #23

@asos-danielc

Description

@asos-danielc

I have the following in my dangerjs.js

import { message, fail, warn, danger } from "danger";
// const { exec } = require("child_process");
import commitlint from "danger-plugin-conventional-commitlint";

import configConventional from "@commitlint/config-conventional";

(async function dangerReport() {
  const commitlintConfig = {
    severity: "warn",
  };
  await commitlint(configConventional.rules, commitlintConfig);
})();

But when run in a github action receive:

Unable to evaluate the Dangerfile
 ./dangerfile.js:4
import commitlint from "danger-plugin-conventional-commitlint";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:[18](https://github.com/app/actions/runs/3510160765/jobs/5879744816#step:6:19))
    at wrapSafe (node:internal/modules/cjs/loader:1084:15)
    at Module._compile (node:internal/modules/cjs/loader:11[19](https://github.com/app/actions/runs/3510160765/jobs/5879744816#step:6:20):27)
...

Is there a working example I can reference?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions