This includes a number of community contributions.
The two liner
#!/bin/sh
echo $FILE_DATA > $FILE_NAME
now turned into a small script:
#!/bin/bash
if [ "$(dirname "$FILE_NAME")" != "." ]
then
mkdir -p "$(dirname "$FILE_NAME")"
fi
if [[ -z "${FILE_BASE64}" ]]; then
echo "Using FILE_DATA to write to $FILE_NAME"
echo $FILE_DATA > "$FILE_NAME"
else
echo "Using FILE_BASE64 to write to $FILE_NAME"
echo $FILE_BASE64 | base64 --decode > $FILE_NAME
fi