Skip to content

Commit

Permalink
modify deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FaithKovi committed Aug 6, 2024
1 parent 3c55cb8 commit 51ce6b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,20 @@ jobs:
terraform init
terraform apply -auto-approve
- name: Decrypt tfvars file, Initialize and Plan Terraform
- name: Decrypt tfvars file and Initialize Terraform
working-directory: ./terraform
run: |
gpg --quiet --batch --yes --decrypt --passphrase="$SECRET_PASSPHRASE" --output variables.tfvars variables.tfvars.gpg
terraform init -reconfigure
terraform plan -out=tfplan -var-file="variables.tfvars" -refresh-only
terraform show -json tfplan | jq '.resource_changes | length'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}

- name: Apply Terraform changes
if: steps.tfplan.outputs.change_count != '0'
working-directory: ./terraform
run: terraform apply -auto-approve "tfplan"
run: terraform apply -auto-approve -var-file="variables.tfvars"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
6 changes: 6 additions & 0 deletions terraform/scripts/empty_bucket.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ set -e
BUCKET_NAME="$1"
AWS_REGION="$2"

# Check if the bucket exists
if ! aws s3api head-bucket --bucket "$BUCKET_NAME" --region "$AWS_REGION" 2>/dev/null; then
echo "Error: Bucket $BUCKET_NAME does not exist in region $AWS_REGION."
exit 1
fi

echo "Deleting all objects and versions from bucket $BUCKET_NAME in region $AWS_REGION"

# Delete all objects
Expand Down

0 comments on commit 51ce6b3

Please sign in to comment.