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

Develop #1

Merged
merged 4 commits into from
May 23, 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
41 changes: 24 additions & 17 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,42 @@ jobs:
- name: Terraform Validate
run: terraform validate

- name: Terraform Create/Select Dev Workspace
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
id: select-dev-workspace
run: |
terraform workspace list | grep -q "dev" || terraform workspace new dev
terraform workspace select dev
# - name: Terraform Create Dev Workspace
# if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
# id: select-dev-workspace
# run: |
# terraform workspace list | grep -q "dev" || terraform workspace new dev

- name: Terraform Plan for Dev
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
id: terraform-plan-dev
run: cd infra && terraform plan -var-file="./envs/dev/terraform.tfvars" -out=dev.plan
run: cd infra &&
terraform workspace select dev || terraform workspace new dev &&
terraform plan -var-file="./envs/dev/terraform.tfvars" -out=dev.plan

- name: Terraform Apply for Dev
id: terraform-apply-dev
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
run: cd infra && terraform apply "dev.plan"
run: cd infra &&
terraform workspace select dev || terraform workspace new dev &&
terraform apply "dev.plan"

- name: Terraform Create/Select Prod Workspace
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
id: select-prod-workspace
run: |
terraform workspace list | grep -q "prod" || terraform workspace new prod
terraform workspace select prod
# - name: Terraform Create Prod Workspace
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
# id: select-prod-workspace
# run: |
# terraform workspace list | grep -q "prod" || terraform workspace new prod

- name: Terraform Plan for Prod
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
id: terraform-plan-prod
run: cd infra && terraform plan -var-file="./envs/prod/terraform.tfvars" -out=prod.plan
run: cd infra &&
terraform workspace select prod || terraform workspace new prod &&
terraform plan -var-file="./envs/prod/terraform.tfvars" -out=prod.plan

- name: Terraform Apply for Prod
id: terraform-apply-prod
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: cd infra && terraform apply "prod.plan"
id: terraform-apply-prod
run: cd infra &&
terraform workspace select prod || terraform workspace new prod &&
terraform apply "prod.plan"
2 changes: 1 addition & 1 deletion infra/envs/dev/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bucket_name="DEV-buildrun-pipeline-123-bucket"
bucket_name="dev-buildrun-pipeline-123-bucket"
2 changes: 1 addition & 1 deletion infra/envs/prod/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bucket_name="PROD-buildrun-pipeline-123-bucket"
bucket_name="prod-buildrun-pipeline-123-bucket"
Loading