Skip to content

Terraform

Terraform #1000

Workflow file for this run

name: 'Terraform'
on:
push:
branches: [master]
schedule:
- cron: '0 0 * * *'
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.14.7
terraform_wrapper: false
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Terraform Init
run: terraform init
- name: Terraform Format
run: terraform fmt -check
- name: Setup Terraform Vars
run: |
cat > .auto.tfvars <<EOF
github_token = "${{ secrets.ORG_ADMIN_GITHUB_TOKEN }}"
mailgun_api_key = "${{ secrets.MAILGUN_API_KEY }}"
EOF
- name: Setup Terraform State
uses: actions/cache@v2
with:
path: terraform.tfstate
key: terraform-state-${{ github.sha }}
restore-keys: terraform-state-
- name: Terraform Import
run: go run ./cmd/import
env:
GITHUB_TOKEN: ${{ secrets.ORG_ADMIN_GITHUB_TOKEN }}
MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }}
- name: Terraform Plan
run: terraform plan -out=tfplan
- name: Terraform Apply
run: terraform apply tfplan
test:
needs: terraform
name: 'Run Tests'
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run Tests
run: go test
env:
GITHUB_TOKEN: ${{ secrets.ORG_ADMIN_GITHUB_TOKEN }}
MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }}