Skip to content

Commit 2c31140

Browse files
Copilotrajbos
andcommitted
refactor: improve workflow maintainability
- Add dedicated step to determine trigger type early - Use trigger_type output to avoid duplicate condition checks - Use boolean input directly without explicit == true comparison - Improves code clarity and maintainability Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
1 parent 73c72e5 commit 2c31140

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ jobs:
3333
node-version: '20.x'
3434
cache: 'npm'
3535

36+
- name: Determine trigger type
37+
id: trigger_type
38+
run: |
39+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
40+
echo "is_manual=true" >> $GITHUB_OUTPUT
41+
echo "Triggered manually via workflow_dispatch"
42+
else
43+
echo "is_manual=false" >> $GITHUB_OUTPUT
44+
echo "Triggered by tag push"
45+
fi
46+
3647
- name: Extract version from package.json
3748
id: package_version
3849
run: |
@@ -41,7 +52,7 @@ jobs:
4152
echo "Package version: $PACKAGE_VERSION"
4253
4354
- name: Create tag for manual trigger
44-
if: github.event_name == 'workflow_dispatch' && inputs.create_tag == true
55+
if: steps.trigger_type.outputs.is_manual == 'true' && inputs.create_tag
4556
env:
4657
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4758
run: |
@@ -65,7 +76,7 @@ jobs:
6576
- name: Extract version from tag
6677
id: extract_version
6778
run: |
68-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
79+
if [ "${{ steps.trigger_type.outputs.is_manual }}" == "true" ]; then
6980
# For manual triggers, use package.json version
7081
TAG_VERSION="${{ steps.package_version.outputs.package_version }}"
7182
else
@@ -89,7 +100,7 @@ jobs:
89100
- name: Determine tag name
90101
id: tag_name
91102
run: |
92-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
103+
if [ "${{ steps.trigger_type.outputs.is_manual }}" == "true" ]; then
93104
TAG_NAME="v${{ steps.extract_version.outputs.tag_version }}"
94105
else
95106
TAG_NAME="${{ github.ref_name }}"

0 commit comments

Comments
 (0)