Skip to content

Commit

Permalink
add extra verification
Browse files Browse the repository at this point in the history
  • Loading branch information
cru-Luis-Rodriguez committed Oct 25, 2024
1 parent 8c282f4 commit 94e3ad8
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/build-deploy-cloudrun-function.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,32 @@ jobs:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: Preprocess Config File
- name: Check for empty variables
run: |
echo "sed_command=s|${FUNCTION_NAME}|${{ inputs.function_name }}|g; \
s|${GCP_REGION}|${{ secrets.GCP_REGION }}|g; \
s|${GCP_PROJECT_ID}|${{ secrets.GCP_PROJECT_ID }}|g; \
s|${GCP_SERVICE_ACCOUNT_EMAIL}|${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}|g; \
s|${RUN_SERVICE_ACCOUNT}|${{ secrets.RUN_SERVICE_ACCOUNT }}|g" >> $GITHUB_ENV
sed -e "s|${FUNCTION_NAME}|${{ inputs.function_name }}|g; \
s|${GCP_REGION}|${{ secrets.GCP_REGION }}|g; \
s|${GCP_PROJECT_ID}|${{ secrets.GCP_PROJECT_ID }}|g; \
s|${GCP_SERVICE_ACCOUNT_EMAIL}|${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}|g; \
s|${RUN_SERVICE_ACCOUNT}|${{ secrets.RUN_SERVICE_ACCOUNT }}|g" \
function_config_template.json > function_config.json
if [ -z "${{ inputs.function_name }}" ] ||
[ -z "${{ secrets.GCP_REGION }}" ] ||
[ -z "${{ secrets.GCP_PROJECT_ID }}" ] ||
[ -z "${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}" ] ||
[ -z "${{ secrets.RUN_SERVICE_ACCOUNT }}" ]; then
echo "One or more required variables are empty."
exit 1
fi
- name: Construct and print sed command
id: print_command
run: |
sed_command="s|${FUNCTION_NAME}|${{ inputs.function_name }}|g; \
s|${GCP_REGION}|${{ secrets.GCP_REGION }}|g; \
s|${GCP_PROJECT_ID}|${{ secrets.GCP_PROJECT_ID }}|g; \
s|${GCP_SERVICE_ACCOUNT_EMAIL}|${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}|g; \
s|${RUN_SERVICE_ACCOUNT}|${{ secrets.RUN_SERVICE_ACCOUNT }}|g"
echo "Running sed command: $sed_command"
eval "echo \"$sed_command\""
- name: Execute sed command
run: |
eval "sed -e \"$sed_command\" function_config_template.json > function_config.json"
- name: Verify Config File
run: cat function_config.json
Expand Down

0 comments on commit 94e3ad8

Please sign in to comment.