Fix handling metadata with single quotes (#90) @goruha (#91)
## what * Change the way how docker build output metadata is processed to handle escape characterwhy
- Metadata JSON from
docker-build-push-actioncontains head/merge commit details includingmessagewhich might include single quotes - get-metadata step wraps the JSON in single quotes causing the build step to break if merge commit contains a single quote character (e.g. as part of commit description):
Run metadata=$(echo '{
...
/home/runner/work/_temp/b76bb997-9a9b-4a18-ac9f-321762ea58ba.sh: line 79: syntax error near unexpected token `('
Error: Process completed with exit code 2.
# OR
/home/runner/_work/_temp/5912f8a7-4a6e-4f73-a4c5-b6730c3ebf58.sh: line 456: unexpected EOF while looking for matching `"'
Error: Process completed with exit code 2.
- Simple way to reproduce the error locally:
metadata=$(echo '{ "message": "that's fine" }' | jq -c)- The native bash way to escape single quotes would be to replace
'with'', however, GHA providetoJSONmethod which automatically escape characters when used in ENV (reference below)