https://github.com/actions/github-script?tab=readme-ov-file#use-esm-import
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ github.token }}
script: |
const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/my_script.mjs`)
await script({context, github, core})// @ts-check
import path from "path";
/** @param {import('@actions/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
export default async ({ context, github, core }) => {
try {
const workDir = core.getInput("WORKDIR", { required: true });
const filename = core.getInput("FILENAME") || "todo.txt";
const filePath = core.toPlatformPath(path.join(workDir, filename));
core.info(filePath);
} catch (error) {
core.setFailed(error.message);
}
};{
"type": "module",
"devDependencies": {
"@actions/github-script": "github:actions/github-script"
}
}