Skip to content

Commit 447f45b

Browse files
authored
fix: fix shared workflow bug (#147)
1 parent 6e74709 commit 447f45b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.github/workflows/shared-check-pr-label-and-branch.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
is_valid_branch: ${{ steps.check.outputs.is_valid_branch }}
3636
steps:
3737
- name: Check for label and branch prefix
38+
env:
39+
LABELS_JSON: ${{ inputs.labels }}
3840
id: check
3941
run: |
4042
TARGET_LABEL="${{ inputs.target_label }}"
@@ -44,7 +46,7 @@ jobs:
4446
echo "Checking for label: $TARGET_LABEL"
4547
echo "Required branch prefix: $BRANCH_PREFIX"
4648
echo "Current branch: $CURRENT_BRANCH"
47-
echo "Input labels: ${{ inputs.labels }}"
49+
echo "Input labels: $LABELS_JSON"
4850
4951
# Check if branch has the required prefix
5052
if [ -n "$BRANCH_PREFIX" ]; then
@@ -61,7 +63,7 @@ jobs:
6163
fi
6264
6365
# Use jq to check if the label exists in the labels array
64-
HAS_LABEL=$(echo '${{ inputs.labels }}' | \
66+
HAS_LABEL=$(echo "$LABELS_JSON" | \
6567
jq --arg target "$TARGET_LABEL" \
6668
'[.[] | select(.name == $target)] | length > 0')
6769
@@ -92,3 +94,5 @@ jobs:
9294
- name: Display Validation Result
9395
run: |
9496
echo "Validation result: ${{ steps.check.outputs.is_valid }}"
97+
echo "Has label: ${{ steps.check.outputs.has_label }}"
98+
echo "Is valid branch: ${{ steps.check.outputs.is_valid_branch }}"

.github/workflows/shared-check-pr-labels-with-prefix.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ jobs:
2828
steps:
2929
- name: Filter labels by prefix
3030
id: filter
31+
env:
32+
LABELS_JSON: ${{ inputs.labels }}
3133
run: |
3234
PREFIX="${{ inputs.prefix }}"
3335
36+
echo "Prefix: $PREFIX"
37+
echo "Input labels: $LABELS_JSON"
38+
3439
# Use jq to filter labels by prefix (empty prefix returns all labels)
35-
JSON_RESULT=$(echo '${{ inputs.labels }}' | \
40+
JSON_RESULT=$(echo "$LABELS_JSON" | \
3641
jq --arg prefix "$PREFIX" \
3742
'map(select(.name | startswith($prefix))) |
3843
map({(.name): .}) |
@@ -49,4 +54,7 @@ jobs:
4954
echo "$JSON_RESULT"
5055
echo "EOF"
5156
} >> $GITHUB_OUTPUT
52-
echo "Labels result: $JSON_RESULT"
57+
58+
- name: Display Filter Result
59+
run: |
60+
echo "Filtered labels: ${{ steps.filter.outputs.filtered-labels }}"

0 commit comments

Comments
 (0)