Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use deploy-environment workflow for int rollback #421

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
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
40 changes: 15 additions & 25 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,31 +355,21 @@ jobs:
needs:
- test_int
- terraform_env_int
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.ENV_int_TF_OIDC_ROLE }}
aws-region: ${{ vars.ENV_int_TF_AWS_REGION }}
- name: Terraform Init
run: terraform init -no-color -input=false
working-directory: infra/terraform/environments/int
- name: Plan Rollback
run: |
terraform plan -no-color -input=false -out=tfplan \
-var "api_image_tag=${{ needs.terraform_env_int.outputs.previous_api_image_tag }}" \
-var "cli_image_tag=${{ needs.terraform_env_int.outputs.previous_cli_image_tag }}" \
-var "selfserve_image_tag=${{ needs.terraform_env_int.outputs.previous_selfserve_image_tag }}" \
-var "internal_image_tag=${{ needs.terraform_env_int.outputs.previous_internal_image_tag }}" \
-var "assets_version=${{ needs.terraform_env_int.outputs.previous_assets_version }}"
working-directory: infra/terraform/environments/int
- name: Apply Rollback
run: terraform apply -no-color -input=false -auto-approve tfplan
working-directory: infra/terraform/environments/int
uses: ./.github/workflows/deploy-environment.yaml
with:
environment: int
rollback: true
apply: true
api-image-tag: ${{ needs.terraform_env_int.outputs.previous_api_image_tag }}
cli-image-tag: ${{ needs.terraform_env_int.outputs.previous_cli_image_tag }}
selfserve-image-tag: ${{ needs.terraform_env_int.outputs.previous_selfserve_image_tag }}
internal-image-tag: ${{ needs.terraform_env_int.outputs.previous_internal_image_tag }}
assets-version: ${{ needs.terraform_env_int.outputs.previous_assets_version }}
permissions:
contents: read
id-token: write
pull-requests: write
secrets: inherit

terraform-account-prod:
name: Account (prod)
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/deploy-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ on:
type: boolean
required: false
default: false
rollback:
type: boolean
required: false
default: false

outputs:
terraform-output:
description: "Terraform output"
Expand Down Expand Up @@ -110,7 +115,7 @@ concurrency:

jobs:
deploy:
name: ${{ inputs.destroy && 'Destroy ' || '' }}${{ inputs.apply && 'Apply' || 'Plan' }}
name: ${{ inputs.rollback && 'Rollback' || '' }}${{ inputs.destroy && 'Destroy ' || '' }}${{ inputs.apply && 'Apply' || 'Plan' }}
runs-on: ubuntu-latest
# As a workaround for: https://github.com/actions/runner/issues/2120
# Environment will not be defined for non-apply jobs to ensure that deployments are kept accurate in the GitHub UI.
Expand Down Expand Up @@ -297,6 +302,18 @@ jobs:
if: ${{ inputs.apply && inputs.destroy && inputs.workspace }}
run: terraform workspace select default && terraform workspace delete ${{ inputs.workspace }}

- name: Add Rollback Notice
if: ${{ inputs.rollback && inputs.apply }}
run: |
echo "## ⚠️ Environment Rollback Performed" >> $GITHUB_STEP_SUMMARY
echo "Environment: ${{ inputs.environment }}" >> $GITHUB_STEP_SUMMARY
echo "Rolled back to:" >> $GITHUB_STEP_SUMMARY
echo "- API: ${{ inputs.api-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "- CLI: ${{ inputs.cli-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "- Selfserve: ${{ inputs.selfserve-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "- Internal: ${{ inputs.internal-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "- Assets: ${{ inputs.assets-version }}" >> $GITHUB_STEP_SUMMARY

- name: Set outputs
if: ${{ always() && !cancelled() && !failure() && !inputs.destroy }}
id: terraform-output
Expand Down
2 changes: 1 addition & 1 deletion app/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ phpcs.xml
phpstan.neon
phpunit.xml
psalm.xml
# Trigger CD - 2024-10-29-0745
# Trigger CD - 2024-10-30-0900