Skip to content

Instantly share code, notes, and snippets.

@roylines
Created September 5, 2021 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roylines/9047128048a87ea5dfba21ef0e6563ba to your computer and use it in GitHub Desktop.
Save roylines/9047128048a87ea5dfba21ef0e6563ba to your computer and use it in GitHub Desktop.
github action: terraform
name: terraform
on:
push:
paths:
- 'terraform/**'
- '.github/workflows/terraform.yml'
jobs:
terraform:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
defaults:
run:
working-directory: terraform
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.6
- run: terraform version
- run: terraform init
- run: terraform plan -out=plan.out
- if: github.ref == 'refs/heads/main'
run: terraform apply -auto-approve plan.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment