-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI/CD workflows for terraform automation
- add transcrypt script - workflow changes to terraform
- Loading branch information
1 parent
2002836
commit 55c06e4
Showing
8 changed files
with
1,917 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Main CD for Devnet Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
paths: | ||
- "aws/devnet/**" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
deploy: | ||
uses: ./.github/workflows/terraform_template_deploy.yml | ||
with: | ||
project: aws | ||
resource: devnet | ||
tf_workspace_name: devnet-aws | ||
tf_version: 1.5.7 | ||
tf_organization: subspace | ||
secrets: | ||
TRANSCRYPT: ${{ secrets.TRANSCRYPT }} | ||
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Main CD for Ephememeral Devnet Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- "!main" | ||
paths: | ||
- "testing-framework/ec2/network/**" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
deploy: | ||
uses: ./.github/workflows/terraform_template_ephemeral_deploy.yml | ||
with: | ||
project: testing-framework | ||
instance: ec2 | ||
resource: network | ||
tf_workspace_name: ephemeral-devnet | ||
tf_version: 1.5.7 | ||
tf_organization: subspace | ||
secrets: | ||
TRANSCRYPT: ${{ secrets.TRANSCRYPT }} | ||
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Main CD for Ephememeral Devnet Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- "!main" | ||
paths: | ||
- "testing-framework/hetzner/network/**" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
deploy: | ||
uses: ./.github/workflows/terraform_template_ephemeral_deploy.yml | ||
with: | ||
project: testing-framework | ||
instance: hetzner | ||
resource: network | ||
tf_workspace_name: ephemeral-devnet-hetzner | ||
tf_version: 1.5.7 | ||
tf_organization: subspace | ||
secrets: | ||
TRANSCRYPT: ${{ secrets.TRANSCRYPT }} | ||
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Main CD for Gemini Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- "!main" | ||
paths: | ||
- "aws/gemini-3f/**" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
deploy: | ||
uses: ./.github/workflows/terraform_template_deploy.yml | ||
with: | ||
project: aws | ||
resource: gemini-3f | ||
tf_workspace_name: gemini-3f | ||
tf_version: 1.5.7 | ||
tf_organization: subspace | ||
secrets: | ||
TRANSCRYPT: ${{ secrets.TRANSCRYPT }} | ||
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: Template Deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
project: | ||
required: true | ||
type: string | ||
resource: | ||
required: true | ||
type: string | ||
tf_workspace_name: | ||
description: "Name of the workspace in terraform cloud" | ||
required: false | ||
type: string | ||
tf_version: | ||
description: "Version of the terraform" | ||
required: true | ||
type: string | ||
tf_organization: | ||
description: "Name of the TF organization" | ||
default: "subspace" | ||
type: string | ||
required: true | ||
run_apply: | ||
description: "The code needs to be deployed or not" | ||
type: string | ||
default: "no" | ||
run_destroy: | ||
description: "The resources need to be destroyed or not" | ||
type: string | ||
default: "no" | ||
secrets: | ||
TRANSCRYPT: | ||
required: true | ||
TF_API_TOKEN: | ||
required: false | ||
env: | ||
TF_CLOUD_ORGANIZATION: "${{ inputs.tf_organization }}" | ||
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" | ||
TF_VERSION: "${{ inputs.tf_version }}" | ||
|
||
jobs: | ||
template-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Decrypt the secrets | ||
run: | | ||
chmod +x ./scripts/transcrypt | ||
scripts/transcrypt -c aes-256-cbc -p ${{ secrets.TRANSCRYPT }} -y | ||
- uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: ${{ env.TF_VERSION }} | ||
terraform_wrapper: false | ||
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | ||
|
||
- name: Setup Remote Config Backend | ||
run: | | ||
cat > config.remote.tfbackend <<EOT | ||
workspaces { name = "${{ inputs.tf_workspace_name }}"} | ||
hostname = "app.terraform.io" | ||
organization = "${{ inputs.tf_organization }}" | ||
EOT | ||
- name: Terraform fmt | ||
working-directory: ${{ inputs.project }}/${{ inputs.resource }} | ||
run: terraform fmt -check | ||
continue-on-error: true | ||
|
||
- name: Terraform Init for ${{ inputs.project }}/${{ inputs.resource }} | ||
working-directory: ${{ inputs.project }}/${{ inputs.resource }} | ||
run: | | ||
cat config.remote.tfbackend | ||
terraform init -backend-config=config.remote.tfbackend | ||
- name: Terraform Validate | ||
working-directory: ${{ inputs.project }}/${{ inputs.resource }} | ||
run: terraform validate | ||
|
||
- name: Fetch and write terraform.tfvars | ||
run: | | ||
echo ${{ secrets.TF_VARS_FILE }} > terraform.tfvars | ||
chmod 600 terraform.tfvars | ||
- name: Terraform Plan for ${{ inputs.project }}/${{ inputs.resource }} | ||
if: ${{ (inputs.run_destroy == 'no') }} | ||
working-directory: ${{ inputs.project }}/${{ inputs.resource }} | ||
run: | | ||
terraform plan -var-file=terraform.tfvars | ||
- name: Terraform Apply for ${{ inputs.project }}/${{ inputs.resource }} | ||
if: ${{ (inputs.run_apply == 'yes') && (inputs.run_destroy == 'no') }} | ||
working-directory: ${{ inputs.project }}/${{ inputs.resource }} | ||
run: | | ||
terraform apply -auto-approve -var-file=terraform.tfvars | ||
- name: Terraform Destroy for ${{ inputs.project }}/${{ inputs.resource }} | ||
if: ${{ (inputs.run_destroy == 'yes') }} | ||
working-directory: ${{ inputs.project }}/${{ inputs.resource }} | ||
run: | | ||
terraform plan -destroy -var-file=terraform.tfvars | ||
terraform destroy -auto-approve -var-file=terraform.tfvars |
Oops, something went wrong.