feat: NCP 인프라를 테라폼을 활용하여 구성합니다 (#9) #1
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: 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 |