Skip to content

Commit

Permalink
fix(inputs): adjust the default for the "branch" configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
cycjimmy committed Oct 28, 2019
1 parent 56568e2 commit e5c555a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GitHub Action for [Semantic Release](https://github.com/semantic-release/semanti

#### Step3: Add a [Workflow File](https://help.github.com/en/articles/workflow-syntax-for-github-actions) to your repository to create custom automated processes.
* inputs:
* `branch`: [Optional] The branch for release. Default `"master"`.
* `branch`: [Optional] The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master.
* `extra_plugins`: [Optional] Extra plugins for pre-install.
* `dry_run`: [Optional] Whether to run semantic release in "dry-run" mode. It will override the dryRun attribute in your configuration file.
* outputs:
Expand Down
3 changes: 1 addition & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ branding:
color: 'orange'
inputs:
branch:
description: 'The branch for release'
default: master
description: 'The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master.'
extra_plugins:
description: 'Extra plugins for pre-install'
dry_run:
Expand Down
17 changes: 16 additions & 1 deletion src/handleOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ const core = require('@actions/core');
const inputs = require('./inputs.json');

/**
* handleDryRunOption
* Handle Branch Option
* @returns {{}|{branch: string}}
*/
exports.handleBranchOption = () => {
const branchOption = {};
const branch = core.getInput(inputs.branch);

if (branch) {
branchOption.branch = branch;
}

return branchOption;
};

/**
* Handle DryRun Option
* @returns {{}|{dryRun: boolean}}
*/
exports.handleDryRunOption = () => {
Expand Down
7 changes: 2 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const core = require('@actions/core');
const semanticRelease = require('semantic-release');
const {handleDryRunOption} = require('./handleOptions');
const {handleBranchOption, handleDryRunOption} = require('./handleOptions');
const setUpJob = require('./setUpJob.task');
const preInstallPlugins = require('./preInstallPlugins.task');
const cleanupNpmrc = require('./cleanupNpmrc.task');
const windUpJob = require('./windUpJob.task');

const inputs = require('./inputs.json');

/**
* Release main task
* @returns {Promise<void>}
Expand All @@ -16,9 +14,8 @@ const release = async () => {
await setUpJob();
await preInstallPlugins();

const branch = core.getInput(inputs.branch) || 'master';
const result = await semanticRelease({
branch,
...(handleBranchOption()),
...(handleDryRunOption()),
});

Expand Down

0 comments on commit e5c555a

Please sign in to comment.