Skip to content

Commit

Permalink
feat(semantic-release): support json branches input
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarJaroudi committed Sep 28, 2023
1 parent 2287ead commit 0c9da75
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion semantic-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
| parameter | description | required | default |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------- |
| branches | Override the branches where semantic release runs on | `false` | |
| branches | Override the branches where semantic release runs on. Accepts string or JSON object. | `false` | |
| ci | Set to false to skip Continuous Integration environment verifications | `false` | |
| dry-run | Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file | `false` | |
| extra-plugins | Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer. Defaults to install @open-turo/semantic-release-config. | `false` | @open-turo/semantic-release-config@^1.4.0 |
Expand Down
2 changes: 1 addition & 1 deletion semantic-release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
default: ${{ github.token }}
branches:
required: false
description: "Override the branches where semantic release runs on"
description: "Override the branches where semantic release runs on. Accepts a string or a JSON object."
ci:
required: false
description: "Set to false to skip Continuous Integration environment verifications"
Expand Down
2 changes: 1 addition & 1 deletion semantic-release/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion semantic-release/dist/index.js.map

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions semantic-release/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const OUTPUTS = {
} as const;

interface Inputs {
branches?: string;
branches?: string | JSON;
ci: boolean;
dryRun: boolean;
extraPlugins: string[];
Expand Down Expand Up @@ -67,8 +67,16 @@ async function runNpmInstall(packages: string[]) {
* Get inputs from the environment
*/
function getInputs(): Inputs {
let branches: string | JSON | undefined;
try {
branches =
process.env.SEMANTIC_ACTION_BRANCHES &&
(JSON.parse(process.env.SEMANTIC_ACTION_BRANCHES) as JSON);
} catch {
branches = process.env.SEMANTIC_ACTION_BRANCHES;
}
return {
branches: process.env.SEMANTIC_ACTION_BRANCHES || undefined,
branches: branches || undefined,
ci: process.env.SEMANTIC_ACTION_CI === "true",
dryRun: process.env.SEMANTIC_ACTION_DRY_RUN === "true",
extraPlugins: (process.env.SEMANTIC_ACTION_EXTRA_PLUGINS || "")
Expand Down

0 comments on commit 0c9da75

Please sign in to comment.