Skip to content

Commit ba0d2a3

Browse files
committed
Fix GitHub workflow function naming and output format
- Use catalog name and strip spaces (HelloWorld-Python-PR-13) - Fix GitHub output format using heredoc to avoid JSON parsing issues - Parse full example objects to get both name and handler
1 parent de0c763 commit ba0d2a3

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/deploy-examples.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,32 @@ jobs:
6767
# Read examples catalog and deploy each function
6868
FUNCTION_NAME_MAP="{}"
6969
70-
for example in $(jq -r '.examples[] | select(.integration == true) | .handler' examples/examples-catalog.json); do
71-
EXAMPLE_NAME=$(echo $example | sed 's/\.handler$//')
70+
for row in $(jq -r '.examples[] | select(.integration == true) | @base64' examples/examples-catalog.json); do
71+
_jq() {
72+
echo ${row} | base64 --decode | jq -r ${1}
73+
}
74+
75+
EXAMPLE_HANDLER=$(_jq '.handler')
76+
EXAMPLE_NAME=$(_jq '.name')
77+
EXAMPLE_NAME_CLEAN=$(echo "$EXAMPLE_NAME" | sed 's/ //g')
78+
HANDLER_FILE=$(echo $EXAMPLE_HANDLER | sed 's/\.handler$//')
7279
7380
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
74-
FUNCTION_NAME="${EXAMPLE_NAME}-Python-PR-$GITHUB_EVENT_NUMBER"
81+
FUNCTION_NAME="${EXAMPLE_NAME_CLEAN}-Python-PR-$GITHUB_EVENT_NUMBER"
7582
else
76-
FUNCTION_NAME="${EXAMPLE_NAME}-Python"
83+
FUNCTION_NAME="${EXAMPLE_NAME_CLEAN}-Python"
7784
fi
7885
79-
echo "Deploying $EXAMPLE_NAME as $FUNCTION_NAME"
80-
hatch run examples:deploy "$EXAMPLE_NAME" "$FUNCTION_NAME"
86+
echo "Deploying $HANDLER_FILE as $FUNCTION_NAME"
87+
hatch run examples:deploy "$HANDLER_FILE" "$FUNCTION_NAME"
8188
8289
# Add to function name map
83-
FUNCTION_NAME_MAP=$(echo $FUNCTION_NAME_MAP | jq --arg key "$EXAMPLE_NAME" --arg value "$FUNCTION_NAME" '. + {($key): $value}')
90+
FUNCTION_NAME_MAP=$(echo $FUNCTION_NAME_MAP | jq --arg key "$HANDLER_FILE" --arg value "$FUNCTION_NAME" '. + {($key): $value}')
8491
done
8592
86-
echo "function-name-map=$FUNCTION_NAME_MAP" >> $GITHUB_OUTPUT
93+
echo "function-name-map<<EOF" >> $GITHUB_OUTPUT
94+
echo "$FUNCTION_NAME_MAP" >> $GITHUB_OUTPUT
95+
echo "EOF" >> $GITHUB_OUTPUT
8796
echo "Function name map: $FUNCTION_NAME_MAP"
8897
8998
cleanup:

0 commit comments

Comments
 (0)