Skip to content

Commit

Permalink
fix: set default values in the entrypoint
Browse files Browse the repository at this point in the history
The action.yml metadata default values for the branches input
wont work if you happen to be referencing a docker image
  • Loading branch information
codfish committed Feb 10, 2024
1 parent 65faef0 commit 1370f92
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
20 changes: 9 additions & 11 deletions action.yml
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }}
15 changes: 12 additions & 3 deletions entrypoint.js
Expand Up @@ -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;
}
};

Expand Down Expand Up @@ -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 })) || [];
Expand Down

0 comments on commit 1370f92

Please sign in to comment.