Skip to content

Terraform

Terraform #77

Workflow file for this run

name: Terraform
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
setup:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.15.4
- name: Terraform Format
id: fmt
run: cd terraform && terraform fmt
- name: Terraform Init
id: init
run: cd terraform && terraform init
- name: Terraform Validate
id: validate
run: cd terraform && terraform validate
- name: Terraform Plan
id: plan
run: cd terraform && terraform plan
continue-on-error: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_US_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_US_SECRET }}
AWS_DEFAULT_REGION: us-east-1
TF_VAR_EU_OS_USERNAME: ${{ secrets.OS_EU_USERNAME }}
TF_VAR_EU_OS_PASSWORD: ${{ secrets.OS_EU_PASSWORD }}
#TF_VAR_VSC_OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_VSC_APPLICATION_CREDENTIAL_ID }}
#TF_VAR_VSC_OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_VSC_APPLICATION_CREDENTIAL_SECRET }}
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
run: cd terraform && terraform apply -auto-approve
continue-on-error: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_US_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_US_SECRET }}
AWS_DEFAULT_REGION: us-east-1
TF_VAR_EU_OS_USERNAME: ${{ secrets.OS_EU_USERNAME }}
TF_VAR_EU_OS_PASSWORD: ${{ secrets.OS_EU_PASSWORD }}
#TF_VAR_VSC_OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_VSC_APPLICATION_CREDENTIAL_ID }}
#TF_VAR_VSC_OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_VSC_APPLICATION_CREDENTIAL_SECRET }}
- name: Commit changed files back
run: |
git add terraform
count=$(git diff --name-only --cached | wc -l)
if (( count > 0 )); then
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
git commit -a -m "[slack-bot] $(date '+%H:%M')"
git push
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}