Skip to content

Commit

Permalink
Split env and build args in update next-vars step
Browse files Browse the repository at this point in the history
  • Loading branch information
ebronson68 committed Nov 20, 2023
1 parent 3aad7d4 commit 26585da
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/ephemeral-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,26 @@ jobs:
run: |
REPOSITORY_NAME=$(echo "${{ github.event.repository.name }}" | awk -F '_' '{print $1}' | tr -d "-")
HOSTNAME="${{ needs.deploy.outputs.hostname }}"
ENVIRONMENT_VARIABLES=""
BUILDARGS=""
while IFS= read -r VAR; do
if echo "${VAR}" | grep -Eq "localhost|${REPOSITORY_NAME}.com";then
VAR=$(echo "${VAR}" | awk -F '=' '{print $1}' | sed "s|$|=${HOSTNAME}|g")
fi
ENVIRONMENT_VARIABLES+="${VAR} "
BUILDARGS="${BUILDARGS} --build-arg ${VAR}"
done < <(cat .env)
ENVIRONMENT_VARIABLES="${{ steps.get-envs.outputs.environmentVariables }}"
BUILDARGS="${{ steps.get-envs.outputs.buildArguments }}"
# Replace URL in ENVIRONMENT_VARIABLES
IFS=' ' read -r -a ENVVARS_ARRAY <<< "${ENVIRONMENT_VARIABLES}"
for VAR in "${ENVVARS_ARRAY[@]}"; do
if echo "${VAR}" | grep -Eq "localhost|${REPOSITORY_NAME}.com";then
VAR=$(echo "${VAR}" | awk -F '=' '{print $1}' | sed "s|$|=${HOSTNAME}|g")
fi
ENVIRONMENT_VARIABLES+="${VAR} "
done
# Replace URL in BUILDARGS
IFS=' ' read -r -a BUILDARGS_ARRAY <<< "${BUILDARGS}"
for VAR in "${BUILDARGS_ARRAY[@]}"; do
if echo "${VAR}" | grep -Eq "localhost|${REPOSITORY_NAME}.com";then
VAR=$(echo "${VAR}" | awk -F '=' '{print $1}' | sed "s|$|=${HOSTNAME}|g")
fi
BUILDARGS="${BUILDARGS} --build-arg ${VAR}"
done
echo "environmentVariables=${ENVIRONMENT_VARIABLES}" >> $GITHUB_OUTPUT
echo "buildArguments=${BUILDARGS}" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 26585da

Please sign in to comment.