From 1370f9298456f85341eba5a53c8f9821687f7e83 Mon Sep 17 00:00:00 2001 From: codfish <1666298+codfish@users.noreply.github.com> Date: Sat, 10 Feb 2024 15:58:47 -0500 Subject: [PATCH] fix: set default values in the entrypoint The action.yml metadata default values for the branches input wont work if you happen to be referencing a docker image --- action.yml | 20 +++++++++----------- entrypoint.js | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index c598a61..99f6c6a 100644 --- a/action.yml +++ b/action.yml @@ -12,17 +12,6 @@ inputs: 'The branches on which releases should happen. https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches' required: false - default: | - [ - 'master', - 'main', - 'next', - 'next-major', - '+([0-9])?(.{+([0-9]),x}).x', - { name: 'beta', prerelease: true }, - { name: 'alpha', prerelease: true }, - { name: 'canary', prerelease: true }, - ] extends: description: 'String or array of modules or file paths containing a shareable configuration. @@ -91,3 +80,12 @@ outputs: runs: using: 'docker' image: 'Dockerfile' + args: + - ${{ inputs.branches }} + - ${{ inputs.extends }} + - ${{ inputs.plugins }} + - ${{ inputs.additional-packages }} + - ${{ inputs.dry-run }} + - ${{ inputs.repository-url }} + - ${{ inputs.tag-format }} + - ${{ inputs.branch }} diff --git a/entrypoint.js b/entrypoint.js index 5fcc062..2007d5b 100644 --- a/entrypoint.js +++ b/entrypoint.js @@ -4,11 +4,11 @@ import semanticRelease from 'semantic-release'; import JSON5 from 'json5'; import arrify from 'arrify'; -const parseInput = (input) => { +const parseInput = (input, defaultValue = '') => { try { return JSON5.parse(input); } catch (err) { - return input; + return defaultValue || input; } }; @@ -74,7 +74,16 @@ const setGitConfigSafeDirectory = () => { */ async function run() { const branch = parseInput(core.getInput('branch', { required: false })); - const branches = parseInput(core.getInput('branches', { required: false })); + const branches = parseInput(core.getInput('branches', { required: false }), [ + 'master', + 'main', + 'next', + 'next-major', + '+([0-9])?(.{+([0-9]),x}).x', + { name: 'beta', prerelease: true }, + { name: 'alpha', prerelease: true }, + { name: 'canary', prerelease: true }, + ]); const plugins = parseInput(core.getInput('plugins', { required: false })); const additionalPackages = parseInput(core.getInput('additional-packages', { required: false })) || [];