Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions .github/workflows/deploy-to-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,21 @@ jobs:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Build dynamic CONFIG_MAP (add S3/CDN + project/stage)
shell: bash
- name: Build config_map.auto.tfvars.json
run: |
# 1) Base vindo do job anterior
BASE='${{ needs.env_setup.outputs.config_map }}'

# 2) Se BASE estiver vazio ou não for JSON -> usa {}
if [ -z "$BASE" ] || ! echo "$BASE" | jq -e . >/dev/null 2>&1; then
BASE='{}'
fi

# 3) Mescla com os campos dinâmicos
MERGED=$(jq -n \
jq -n \
--argjson base "$BASE" \
--arg bucket '${{ needs.build_uploads.outputs.bucket_name }}' \
--arg cdn '${{ needs.build_uploads.outputs.cdn_url }}' \
--arg project '${{ needs.env_setup.outputs.project_name }}' \
--arg stage '${{ needs.env_setup.outputs.stage }}' \
'$base + { S3_BUCKET: $bucket, CDN_DOMAIN: $cdn, PROJECT_NAME: $project, STAGE: $stage }')

# 4) Exporta para o ambiente no formato que o Terraform entende (JSON puro)
echo "TF_VAR_config_map=$MERGED" >> "$GITHUB_ENV"

- name: Show merged CONFIG_MAP
run: echo "$TF_VAR_config_map" | jq .
'{ config_map: ( $base + { S3_BUCKET: $bucket, CDN_DOMAIN: $cdn, PROJECT_NAME: $project, STAGE: $stage } ) }' \
> iac/config_map.auto.tfvars.json

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
Expand Down