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