Created
December 15, 2019 06:48
-
-
Save yamashun/564ff4e5032d828527c51c194171ba65 to your computer and use it in GitHub Desktop.
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: 'Terraform GitHub Actions' | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
jobs: | |
terraform: | |
name: 'Terraform' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
env: [dev, prod] | |
workdir: [./service1/ec2, ./service2/ec2, ./service1/iam-role, ./service2/iam-role] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
TF_WORKSPACE: ${{ matrix.env }} | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@master | |
- name: 'Terraform Format' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: 0.12.17 | |
tf_actions_subcommand: 'fmt' | |
tf_actions_working_dir: ${{ matrix.workdir }} | |
- name: 'Terraform Init' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: 0.12.17 | |
tf_actions_subcommand: 'init' | |
tf_actions_working_dir: ${{ matrix.workdir }} | |
- name: 'Terraform Validate' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: 0.12.17 | |
tf_actions_subcommand: 'validate' | |
tf_actions_working_dir: ${{ matrix.workdir }} | |
- name: 'Terraform Plan' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: 0.12.17 | |
tf_actions_subcommand: 'plan' | |
tf_actions_working_dir: ${{ matrix.workdir }} | |
- name: 'Terraform Apply' | |
if: github.ref == 'refs/heads/master' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: 0.12.17 | |
tf_actions_subcommand: 'apply' | |
tf_actions_working_dir: ${{ matrix.workdir }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment