Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ Thumbs.db
__tests__/runner/*
/lib/
/dist/
/.idea/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"package": "ncc build",
"package": "NODE_OPTIONS=--openssl-legacy-provider ncc build",
"test": "jest",
"all": "yarn build && yarn format && yarn lint && yarn package && yarn test"
},
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getInput, setFailed, setOutput, info } from '@actions/core';
import { determineVersion } from './determine-version';
import { validateHistoryDepth, checkout, createTag, refExists } from './git';
import { getEnv } from './utils';
import { getEnv, getEnvOrNull } from './utils';

const VERSION_PLACEHOLDER = /{VERSION}/g;

Expand All @@ -14,7 +14,9 @@ async function run(): Promise<void> {
info(`Previous version: ${previousVersion}`);
setOutput('previous-version', previousVersion);

await checkout(getEnv('GITHUB_REF'));
const checkoutRef = getEnvOrNull('GITHUB_HEAD_REF') || getEnv('GITHUB_REF');

await checkout(checkoutRef);

let currentVersion = await determineVersion();

Expand Down
10 changes: 9 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
export function getEnv(name: string): string {
export function getEnvOrNull(name: string): string | null {
let value = process.env[name];
if (typeof value === 'string') {
return value;
}
return null;
}

export function getEnv(name: string): string {
let value = getEnvOrNull(name);
if (typeof value === 'string') {
return value;
}

throw new Error(`Missing environment variable ${name}`);
}
Loading