Skip to content

Commit 805db24

Browse files
committed
chore/security : reuse yaml without conversion
1 parent 922849f commit 805db24

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ jobs:
3535
# Verify project exists in configuration
3636
CONFIG_FILE=".github/config/build-matrices.yaml"
3737
38-
# Convert YAML to JSON once for easier processing
39-
CONFIG_JSON=$(yq eval '.' "$CONFIG_FILE" -o=json)
40-
41-
# Check if project exists using jq on the converted JSON
42-
if ! echo "$CONFIG_JSON" | jq -e ".projects | has(\"$PROJECT\")" > /dev/null; then
38+
# Check if project exists in YAML directly
39+
if ! yq eval ".projects | has(\"$PROJECT\")" "$CONFIG_FILE" | grep -q "true"; then
4340
echo "Project '$PROJECT' is not configured!"
4441
echo "Available projects:"
45-
echo "$CONFIG_JSON" | jq -r '.projects | keys[]' | sed 's/^/ - /'
42+
yq eval '.projects | keys | .[]' "$CONFIG_FILE" | sed 's/^/ - /'
4643
exit 1
4744
fi
4845
@@ -56,23 +53,17 @@ jobs:
5653
echo "project=$PROJECT" >> $GITHUB_OUTPUT
5754
echo "version=$VERSION" >> $GITHUB_OUTPUT
5855
59-
# Load build matrix configuration from converted JSON
56+
# Load build matrix configuration directly from YAML
6057
echo "Loading matrix configuration for project: $PROJECT"
6158
62-
# Extract the project configuration using jq on the converted JSON
63-
PROJECT_CONFIG=$(echo "$CONFIG_JSON" | jq ".projects.${PROJECT}")
59+
# Extract the include section directly and output as compact JSON
60+
MATRIX_JSON=$(yq eval ".projects.${PROJECT}" "$CONFIG_FILE" -o=json -I=0)
6461
65-
if [[ "$PROJECT_CONFIG" == "null" ]]; then
62+
if [[ "$MATRIX_JSON" == "null" ]]; then
6663
echo "No configuration found for project '$PROJECT'!"
6764
exit 1
6865
fi
6966
70-
# Extract just the include section or create empty array if it doesn't exist
71-
MATRIX=$(echo "$PROJECT_CONFIG" | jq -c '.include // []')
72-
73-
# Wrap in the expected matrix format
74-
MATRIX_JSON="{\"include\":$MATRIX}"
75-
7667
echo "Matrix configuration loaded successfully"
7768
echo "MATRIX: $MATRIX_JSON"
7869
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)