Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { fileExists, diffTable, toBool, stripHash } from './utils.js';
/**
* @typedef {ReturnType<typeof import("@actions/github").getOctokit>} Octokit
* @typedef {typeof import("@actions/github").context} ActionContext
* @param {Octokit} octokit
* @param {ActionContext} context
* @param {string} token
* @param {Octokit} octokit
* @param {ActionContext} context
* @param {string} token
*/
async function run(octokit, context, token) {
const { owner, repo, number: pull_number } = context.issue;
Expand Down Expand Up @@ -51,13 +51,17 @@ async function run(octokit, context, token) {
const cwd = process.cwd();

let yarnLock = await fileExists(path.resolve(cwd, 'yarn.lock'));
let pnpmLock = await fileExists(path.resolve(cwd, 'pnpm-lock.yaml'));
let packageLock = await fileExists(path.resolve(cwd, 'package-lock.json'));

let npm = `npm`;
let installScript = `npm install`;
if (yarnLock) {
installScript = npm = `yarn --frozen-lockfile`;
}
else if (pnpmLock) {
installScript = `pnpm install --frozen-lockfile`;
}
else if (packageLock) {
installScript = `npm ci`;
}
Expand All @@ -71,7 +75,7 @@ async function run(octokit, context, token) {
console.log(`Building using ${npm} run ${buildScript}`);
await exec(`${npm} run ${buildScript}`);
endGroup();

// In case the build step alters a JSON-file, ....
await exec(`git reset --hard`);

Expand Down Expand Up @@ -117,11 +121,15 @@ async function run(octokit, context, token) {
startGroup(`[base] Install Dependencies`);

yarnLock = await fileExists(path.resolve(cwd, 'yarn.lock'));
pnpmLock = await fileExists(path.resolve(cwd, 'pnpm-lock.yaml'));
packageLock = await fileExists(path.resolve(cwd, 'package-lock.json'));

if (yarnLock) {
installScript = npm = `yarn --frozen-lockfile`;
}
else if (pnpmLock) {
installScript = `pnpm install --frozen-lockfile`;
}
else if (packageLock) {
installScript = `npm ci`;
}
Expand Down Expand Up @@ -256,8 +264,8 @@ async function run(octokit, context, token) {

/**
* Create a check and return a function that updates (completes) it
* @param {Octokit} octokit
* @param {ActionContext} context
* @param {Octokit} octokit
* @param {ActionContext} context
*/
async function createCheck(octokit, context) {
const check = await octokit.checks.create({
Expand Down