adding #64
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
name: Deploy Terraform Code to ACG | |
defaults: | |
run: | |
shell: bash | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
jobs: | |
bitbucket_mirror: | |
name: Mirror to Bitbucket | |
runs-on: ubuntu-latest | |
environment: 'prod' | |
steps: | |
- name: Checkout the Repository to the runner | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 'true' | |
- name: Copy Repository | |
run: git push --mirror https://x-token-auth:${{ secrets.AUTH_TOKEN }}@bitbucket.org/currtis1-lab/terraform-playground.git | |
tf_fmt_plan_000base: | |
name: Terraform Format and Plan 000Base | |
runs-on: ubuntu-latest | |
environment: 'prod' | |
defaults: | |
run: | |
working-directory: ./layers/000base | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout the repository to the runner | |
uses: actions/checkout@v2 | |
- name: Setup Terraform with specified version on the runner | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.5.5 | |
terraform_wrapper: true | |
- name: Terraform init | |
id: init | |
run: terraform init | |
- name: Terraform format | |
id: fmt | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Terraform Plan | |
id: plan | |
run: | | |
export exitcode=0 | |
terraform plan -detailed-exitcode -no-color -out 000base_tfplan || export exitcode=$? | |
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT | |
if [ $exitcode -eq 1 ]; then | |
echo Terraform Plan Failed! | |
exit 1 | |
else | |
exit 0 | |
fi | |
- name: Publish Terraform Plan | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 000base_tfplan | |
path: ./layers/000base/000base_tfplan | |
tf_apply_000base: | |
name: Terraform Apply 000Base | |
timeout-minutes: 30 | |
needs: tf_fmt_plan_000base | |
runs-on: ubuntu-latest | |
environment: 'prod' | |
defaults: | |
run: | |
working-directory: ./layers/000base | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout the repository to the runner | |
uses: actions/checkout@v2 | |
- name: Setup Terraform with specified version on the runner | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.5.5 | |
- name: Terraform init | |
id: init | |
run: terraform init | |
- name: Download Terraform Plan | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./layers/000base/000base_tfplan | |
name: 000base_tfplan | |
- run: | | |
cd ./000base_tfplan | |
ls -la | |
- name: Terraform Apply | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: terraform apply -auto-approve ./000base_tfplan | |
tf_fmt_plan_100security: | |
name: Terraform Format and Plan 100security | |
needs: tf_apply_000base | |
runs-on: ubuntu-latest | |
environment: 'prod' | |
defaults: | |
run: | |
working-directory: ./layers/100security | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout the repository to the runner | |
uses: actions/checkout@v2 | |
- name: Setup Terraform with specified version on the runner | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.5.5 | |
- name: Terraform init | |
id: init | |
run: terraform init | |
- name: Terraform format | |
id: fmt | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan | |
tf_apply_100Security: | |
name: Terraform Apply 100Security | |
timeout-minutes: 30 | |
needs: [tf_fmt_plan_100Security, tf_apply_000base] | |
runs-on: ubuntu-latest | |
environment: 'prod' | |
defaults: | |
run: | |
working-directory: ./layers/100security | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout the repository to the runner | |
uses: actions/checkout@v2 | |
- name: Setup Terraform with specified version on the runner | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.5.5 | |
- name: Terraform init | |
id: init | |
run: terraform init | |
- name: Terraform Apply | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: terraform apply -auto-approve -input=false |