Skip to content

Commit

Permalink
Add matched output to parse action
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangoree committed Dec 20, 2023
1 parent fe6a1c7 commit fa57e35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/actions/parse-ref-semver/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ inputs:
description: 'The github ref to parse (e.g. refs/tags/v1.0.0, refs/tags/[email protected])'
required: true
outputs:
matched:
description: \"true\" if the ref matched the semver pattern, \"false\" otherwise
package-scope:
description: The package scope (if any) from the tag (e.g. @scope/[email protected] -> scope)
package-name:
Expand Down
4 changes: 3 additions & 1 deletion .github/actions/parse-ref-semver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ try {
);

if (!match) {
throw new Error('Tag does not match the expected format');
core.setOutput('matched', false);
return;
}

const [
Expand All @@ -38,6 +39,7 @@ try {
build,
] = match;

core.setOutput('matched', true);
core.setOutput('scope', scope);
core.setOutput('name', name);
core.setOutput('major', major);
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-parse-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
uses: ./.github/actions/parse-ref-semver
id: parse
with:
ref: ${{ github.ref }}
ref: refs/tags/@scope/[email protected]+build.123

- name: Print outputs
if: ${{ steps.parse.outputs.matched == 'true' }}
run: |
echo "package-scope=${{ steps.parse.outputs.package-scope }}"
echo "package-name=${{ steps.parse.outputs.package-name }}"
Expand Down

0 comments on commit fa57e35

Please sign in to comment.