Skip to content

add init script in destroy makefile #6

add init script in destroy makefile

add init script in destroy makefile #6

name: 'Terraform destroy'
on:
push:
branches: [ "main" ]
schedule:
- cron: "0 15 * * 1-5" # UTC standard -> KRT = UTC + 9, KRT 13:00 = 04:00 + 9
permissions:
contents: read
jobs:
terraform-destroy:
name: 'Terraform destroy'
runs-on: ubuntu-latest
environment: production
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
# Install the latest version of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
# Configure AWS credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
# Create terraform.prod.tfvars file
- name: Create terraform.prod.tfvars file
run: echo "dockerhub_id = ${{ secrets.DOCKERHUB_id }}" >> terraform.prod.tfvars
- run: echo "dockerhub_pwd = ${{ secrets.DOCKERHUB_pwd }}" >> terraform.prod.tfvars
# Create google cloud service account credential.json file
- name: Configure GCP service account credentials
run: echo "${{ secrets.GCP_SERVICE_ACCOUNT_JSON_VALUE }}" > credentials.json
# destroy GCP instance
- name: Create GCP Compute Engine
run: make clean