GKE Cluster #5
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: GKE Cluster | |
on: | |
workflow_dispatch: | |
inputs: | |
action: | |
description: 'Action' | |
required: false | |
default: 'apply' | |
type: choice | |
options: | |
- apply | |
- destroy | |
jobs: | |
cluster: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Authenticate into gcloud | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | |
- name: Install gcloud CLI | |
uses: google-github-actions/[email protected] | |
- name: Install gcloud k8s auth component | |
run: gcloud components install gke-gcloud-auth-plugin | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
- name: Create Terraform Cloud descriptor | |
run: cp ./gke/terraform.cloud.tf.example ./gke/terraform.cloud.tf | |
- name: Stand up GKE cluster | |
run: | | |
cd gke | |
terraform init | |
terraform ${{ inputs.action }} \ | |
--var="project=${{ secrets.GCP_PROJECT }}" \ | |
--var="cluster_location=${{ vars.GCP_CLUSTER_LOCATION }}" \ | |
--var="cluster_machine_type=${{ vars.GCP_CLUSTER_MACHINE_TYPE }}" \ | |
--auto-approve |