Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/local.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import { resolve } from "path";
import { resolve } from "path"; // Import 'resolve' to construct absolute file paths

// Define an asynchronous function to set up environment variables and run the main script
async function run() {
// Map environment variables to GitHub Action input format
[
["github-token", "GITHUB_TOKEN"],
["merge-method", "MERGE_METHOD"],
["github-token", "GITHUB_TOKEN"], // Maps GITHUB_TOKEN to INPUT_GITHUB_TOKEN
["merge-method", "MERGE_METHOD"], // Maps MERGE_METHOD to INPUT_MERGE_METHOD
].forEach(([inputName, envInputVariable]) => {
// If the environment variable exists, convert and assign it as a GitHub Action input
if (process.env[envInputVariable]) {
process.env[`INPUT_${inputName.replace(/ /g, "_").toUpperCase()}`] =
process.env[envInputVariable];
}
});

// Set the GitHub event path to a stub JSON file (simulating a pull request event)
process.env[`GITHUB_EVENT_PATH`] = resolve(
__dirname,
"..",
"stub",
"example-pull-request.json",
);

// Load and execute the main script
require("./main");
}

// Run the setup function
run();