Created
December 15, 2019 08:30
-
-
Save yamashun/13f5650974ecd54a3b58153cd434a72c 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 | |
paths: | |
- service2/** | |
- modules/** | |
push: | |
branches: | |
- master | |
paths: | |
- service2/** | |
- modules/** | |
jobs: | |
terraform: | |
name: 'Terraform' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
env: [dev, prod] | |
workdir: [./service2/ec2, ./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