-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
36 lines (36 loc) · 1.06 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: 'env vars to dotenv'
author: 'Fahad Munir ( @fmunirdev )'
description: 'Composite action to append environment variables to a dotenv file.'
branding:
icon: 'file-plus'
color: 'gray-dark'
inputs:
variableName:
description: 'Single env var name'
required: false
variableNames:
description: 'Comma separated names of env vars'
required: false
target:
description: 'The env file that will be created'
required: false
default: '.env'
runs:
using: 'composite'
steps:
- run: |
if [ ! -d "`dirname ${{ inputs.target }}`" ] ; then
mkdir -p `dirname ${{ inputs.target }}`
fi
if [ ! -z "${{ inputs.variableName }}" ] ; then
VAR_NAME=${{ inputs.variableName }}
echo $VAR_NAME=`eval echo '${!VAR_NAME}'` >> ${{ inputs.target }}
fi
if [ ! -z "${{ inputs.variableNames }}" ] ; then
IFS=','
for i in `echo "${{ inputs.variableNames }}"`
do
echo $i=`eval echo '${!i}'` >> ${{ inputs.target }}
done
fi
shell: bash