From d87330656527adabd8da2c5ae044fdd7b834383f Mon Sep 17 00:00:00 2001 From: Jerome Dassonville Date: Tue, 19 Mar 2024 16:55:17 +0100 Subject: [PATCH] fix: shellcheck style errors --- .github/workflows/docker-push-v2.yml | 2 +- .github/workflows/ecs-deploy-v2.yml | 10 +++++----- .github/workflows/terraform-apply-v2.yml | 2 +- .github/workflows/terraform-plan-ecs-v2.yml | 15 +++++++-------- .github/workflows/terraform-plan-v2.yml | 10 +++++----- .github/workflows/version-v2.yml | 16 ++++++++-------- 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.github/workflows/docker-push-v2.yml b/.github/workflows/docker-push-v2.yml index 900eb9f..5836fa8 100644 --- a/.github/workflows/docker-push-v2.yml +++ b/.github/workflows/docker-push-v2.yml @@ -81,7 +81,7 @@ jobs: id: set_ssh if: ${{ inputs.use_ssh }} run: | - echo "ssh=main=$SSH_AUTH_SOCK" >> ${GITHUB_OUTPUT} + echo "ssh=main=$SSH_AUTH_SOCK" >> "${GITHUB_OUTPUT}" - name: Build and push (with cache) if: ${{ inputs.cache_docker_layers }} diff --git a/.github/workflows/ecs-deploy-v2.yml b/.github/workflows/ecs-deploy-v2.yml index 06af569..ce1bd37 100644 --- a/.github/workflows/ecs-deploy-v2.yml +++ b/.github/workflows/ecs-deploy-v2.yml @@ -93,9 +93,9 @@ jobs: - name: Get current version id: current_version run: | - CURRENT_TASK_DEFINITION=$(aws ecs list-task-definitions | jq --arg SERVICE "$SERVICE" --arg ENVIRONMENT "$ENV" -r -c '.taskDefinitionArns[] | select(contains($SERVICE + "-" + $ENVIRONMENT))') - CURRENT_IMAGE_TAG=$(aws ecs describe-task-definition --task-definition $CURRENT_TASK_DEFINITION | jq --arg SERVICE "$SERVICE" -r -c '.taskDefinition.containerDefinitions[] | select(.name == $SERVICE) | .image' | cut -d':' -f2) - echo "image_tag=$CURRENT_IMAGE_TAG" >> $GITHUB_OUTPUT + CURRENT_TASK_DEFINITION="$(aws ecs list-task-definitions | jq --arg SERVICE "$SERVICE" --arg ENVIRONMENT "$ENV" -r -c '.taskDefinitionArns[] | select(contains($SERVICE + "-" + $ENVIRONMENT))')" + CURRENT_IMAGE_TAG="$(aws ecs describe-task-definition --task-definition "$CURRENT_TASK_DEFINITION" | jq --arg SERVICE "$SERVICE" -r -c '.taskDefinition.containerDefinitions[] | select(.name == $SERVICE) | .image' | cut -d':' -f2)" + echo "image_tag=$CURRENT_IMAGE_TAG" >> "$GITHUB_OUTPUT" - name: Notify deployment in progress uses: sencrop/github-workflows/actions/notify-deployment-in-progress@master @@ -108,12 +108,12 @@ jobs: slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }} - name: Terraform apply - run: terraform apply -var "docker_image_tag=${DOCKER_IMAGE_TAG}" -var-file=${ENV}.tfvars -auto-approve -input=false ${EXTRA_ARGS} + run: terraform apply -var "docker_image_tag=${DOCKER_IMAGE_TAG}" -var-file="${ENV}.tfvars" -auto-approve -input=false "${EXTRA_ARGS}" - name: Wait for stabilization if: ${{ inputs.wait_for_stabilization }} run: | - if !(aws ecs wait services-stable --cluster "main-${ENV}" --service "${SERVICE}"); then + if ! (aws ecs wait services-stable --cluster "main-${ENV}" --service "${SERVICE}"); then echo "/!\/!\/!\ The deployment has failed to stabilize after 10 minutes !" echo "It likely means that this new version is crashing on start up." echo "You should check the logs to understand what happened: ${LOGS_URL}" diff --git a/.github/workflows/terraform-apply-v2.yml b/.github/workflows/terraform-apply-v2.yml index ab2698b..6cc336f 100644 --- a/.github/workflows/terraform-apply-v2.yml +++ b/.github/workflows/terraform-apply-v2.yml @@ -71,4 +71,4 @@ jobs: run: terraform validate - name: Terraform apply - run: terraform apply -var-file=${ENV}.tfvars -auto-approve -input=false ${EXTRA_ARGS} + run: terraform apply -var-file="${ENV}.tfvars" -auto-approve -input=false "${EXTRA_ARGS}" diff --git a/.github/workflows/terraform-plan-ecs-v2.yml b/.github/workflows/terraform-plan-ecs-v2.yml index e0f177e..2921402 100644 --- a/.github/workflows/terraform-plan-ecs-v2.yml +++ b/.github/workflows/terraform-plan-ecs-v2.yml @@ -75,9 +75,8 @@ jobs: # and will likely ignore it the day it really matters - name: Get current image tag run: | - REF=$(aws ecs describe-task-definition --task-definition "${SERVICE}-${ENV}" --output json | jq -r '.taskDefinition.containerDefinitions[] | select(.name == "'${SERVICE}'") | .image | split(":")[1]') - echo ${REF} - echo "REF=$REF" >> ${GITHUB_ENV} + REF="$(aws ecs describe-task-definition --task-definition "${SERVICE}-${ENV}" --output json | jq --arg SERVICE "$SERVICE" -r '.taskDefinition.containerDefinitions[] | select(.name == $SERVICE) | .image | split(":")[1]')" + echo "REF=$REF" >> "${GITHUB_ENV}" - name: Terraform setup uses: sencrop/github-workflows/actions/setup-terraform@master @@ -94,7 +93,7 @@ jobs: # inspired by https://blog.testdouble.com/posts/2021-12-07-elevate-your-terraform-workflow-with-github-actions/ - name: Terraform plan id: plan - run: terraform plan -var docker_image_tag=${REF} -var-file=${ENV}.tfvars -input=false -no-color -out=tfplan ${EXTRA_ARGS} + run: terraform plan -var docker_image_tag="${REF}" -var-file="${ENV}.tfvars" -input=false -no-color -out=tfplan "${EXTRA_ARGS}" # 1. remove everything before the plan output # 2. remove github actions output @@ -115,10 +114,10 @@ jobs: - name: Put Plan in Env Var run: | sed 's|`|\\\`|g' plan.txt > safe_plan.txt - PLAN=$(cat safe_plan.txt) - echo "PLAN<> $GITHUB_ENV - echo "$PLAN" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + PLAN="$(cat safe_plan.txt)" + echo "PLAN<> "$GITHUB_ENV" + echo "$PLAN" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" - uses: actions/github-script@v6 if: github.event_name == 'pull_request' diff --git a/.github/workflows/terraform-plan-v2.yml b/.github/workflows/terraform-plan-v2.yml index 9cba266..76f2ae7 100644 --- a/.github/workflows/terraform-plan-v2.yml +++ b/.github/workflows/terraform-plan-v2.yml @@ -79,7 +79,7 @@ jobs: # inspired by https://blog.testdouble.com/posts/2021-12-07-elevate-your-terraform-workflow-with-github-actions/ - name: Terraform plan id: plan - run: terraform plan -var-file=${ENV}.tfvars -input=false -no-color -out=tfplan ${EXTRA_ARGS} + run: terraform plan -var-file="${ENV}.tfvars" -input=false -no-color -out=tfplan "${EXTRA_ARGS}" # 1. remove everything before the plan output # 2. remove github actions output @@ -100,10 +100,10 @@ jobs: - name: Put Plan in Env Var run: | sed 's|`|\\\`|g' plan.txt > safe_plan.txt - PLAN=$(cat safe_plan.txt) - echo "PLAN<> $GITHUB_ENV - echo "$PLAN" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + PLAN="$(cat safe_plan.txt)" + echo "PLAN<> "$GITHUB_ENV" + echo "$PLAN" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" - uses: actions/github-script@v6 if: github.event_name == 'pull_request' diff --git a/.github/workflows/version-v2.yml b/.github/workflows/version-v2.yml index 003c514..baa3ee0 100644 --- a/.github/workflows/version-v2.yml +++ b/.github/workflows/version-v2.yml @@ -30,16 +30,16 @@ jobs: if: "! inputs.use_tags" id: git_hash run: | - REF=$(git rev-parse --short HEAD) - PREVIOUS_REF=$(git rev-parse --short HEAD~1) - echo "REF=$REF" >> ${GITHUB_OUTPUT} - echo "PREVIOUS_REF=$PREVIOUS_REF" >> ${GITHUB_OUTPUT} + REF="$(git rev-parse --short HEAD)" + PREVIOUS_REF="$(git rev-parse --short HEAD~1)" + echo "REF=$REF" >> "${GITHUB_OUTPUT}" + echo "PREVIOUS_REF=$PREVIOUS_REF" >> "${GITHUB_OUTPUT}" - name: Get version from tags if: inputs.use_tags id: git_tags run: | - REF=${GITHUB_REF#refs/tags/} - PREVIOUS_REF=$(git tag -l 'v*' --sort=-v:refname | head -n2 | tail -n1) - echo "REF=$REF" >> ${GITHUB_OUTPUT} - echo "PREVIOUS_REF=$PREVIOUS_REF" >> ${GITHUB_OUTPUT} + REF="${GITHUB_REF#refs/tags/}" + PREVIOUS_REF="$(git tag -l 'v*' --sort=-v:refname | head -n2 | tail -n1)" + echo "REF=$REF" >> "${GITHUB_OUTPUT}" + echo "PREVIOUS_REF=$PREVIOUS_REF" >> "${GITHUB_OUTPUT}"