Files
prepare-env-file/action.yml
2025-03-30 11:40:55 +02:00

48 lines
1.4 KiB
YAML

name: 'Prepare Environment'
description: 'Prepares .env file with necessary variables'
inputs:
stack_name:
description: 'Stack name'
required: true
outputs:
exists:
description: 'Whether .env file exists'
value: 'true'
content:
description: 'Base64 encoded content of .env file'
value: ${{ steps.encode.outputs.content }}
runs:
using: 'composite'
steps:
- id: prepare
shell: bash
run: |
echo "DEBUG: Checking if .env file exists"
if [ ! -f ".env" ]; then
echo "DEBUG: .env file not found, creating new one"
touch .env
else
echo "DEBUG: .env file already exists, using existing file"
fi
echo "DEBUG: Checking if STACK_NAME is already set in .env"
if grep -q "STACK_NAME=" .env; then
echo "DEBUG: STACK_NAME found in .env, updating value to '${{ inputs.stack_name }}'"
sed -i "s/STACK_NAME=.*/STACK_NAME=${{ inputs.stack_name }}/" .env
else
echo "DEBUG: STACK_NAME not found in .env, adding value '${{ inputs.stack_name }}'"
echo "STACK_NAME=${{ inputs.stack_name }}" >> .env
fi
echo "DEBUG: Final .env file content:"
cat .env
- id: encode
shell: bash
run: |
echo "DEBUG: Encoding .env file to base64"
ENV_BASE64=$(base64 -w 0 .env)
echo "content=$ENV_BASE64" >> $GITHUB_OUTPUT
echo "DEBUG: .env file encoded successfully"