Skip to content

feat: NCP 인프라를 테라폼을 활용하여 구성합니다 (#9) #1

feat: NCP 인프라를 테라폼을 활용하여 구성합니다 (#9)

feat: NCP 인프라를 테라폼을 활용하여 구성합니다 (#9) #1

name: NCP IaC
on:
push:
branches:
- infra/main
workflow_dispatch:
jobs:
terraform:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
working-directory: ./infra/terraform
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Terraform Setup
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.8.2
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Init
working-directory: ${{ env.working-directory }}
run: terraform init
- name: Terraform Format
working-directory: ${{ env.working-directory }}
run: terraform fmt -check
- name: Terraform Plan
working-directory: ${{ env.working-directory }}
run: terraform plan -var=ncp_access_key=${{ secrets.NCP_ACCESS_KEY_ID }} -var=ncp_secret_key=${{ secrets.NCP_SECRET_ACCESS_KEY }} -input=false
- name: Terraform Apply
working-directory: ${{ env.working-directory }}
if: github.ref == 'refs/heads/infra/main' && github.event_name == 'push'
run: terraform apply -auto-approve -var=ncp_access_key=${{ secrets.NCP_ACCESS_KEY_ID }} -var=ncp_secret_key=${{ secrets.NCP_SECRET_ACCESS_KEY }} -input=false