Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

fix: Explicitly create SLO services when installation with ASM is launched #43

fix: Explicitly create SLO services when installation with ASM is launched

fix: Explicitly create SLO services when installation with ASM is launched #43

Workflow file for this run

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Terraform
on:
pull_request:
types: [opened,synchronize,reopened]
paths:
- 'provisioning/terraform/**'
jobs:
tflint:
runs-on: ubuntu-latest
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Terraform backend initialization
run: terraform -chdir=./provisioning/terraform/ init -backend=false
- name: Cache plugin dir
uses: actions/cache@v3
with:
path: ~/.tflint.d/plugins
key: tflint-${{ hashFiles('.tflint.hcl') }}
- name: Setup TFLint
uses: terraform-linters/setup-tflint@v3
with:
tflint_version: v0.45.0
- name: Show version
run: tflint --version
- name: Init TFLint
run: tflint --init
env:
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
GITHUB_TOKEN: ${{ github.token }}
- name: TF Linting
run: tflint -f compact --chdir ./provisioning/terraform
- name: Linting convenience shell scripts
run: shellcheck provisioning/terraform/**/*.sh
e2e-deployment:
needs: tflint
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Authenticate to Google Cloud
id: 'auth'
uses: google-github-actions/auth@v1
with:
token_format: 'access_token'
workload_identity_provider: ${{ secrets.E2E_IDENTITY_PROVIDER }}
service_account: ${{ secrets.E2E_SERVICE_ACCOUNT }}
- name: Setup GCloud CLI
uses: google-github-actions/setup-gcloud@v1
with:
install_components: 'gke-gcloud-auth-plugin'
# select a zone in us-central1 region and use it to next steps as ${{ env.cluster_location }}
- name: Setup deployment location to random zone
run: |-
zones=("us-central1-a" "us-central1-b" "us-central1-c" "us-central1-f")
selected_location=${zones[ $RANDOM % ${#zones[@]} ]}
echo "Terraform will provision GKE cluster in \"${selected_location}\""
echo "cluster_location=${selected_location}" >> $GITHUB_ENV
- name: Deploy Online Boutique with Sandbox
env:
SHA: ${{ github.sha }}
run: |-
cd "${{ github.workspace }}/provisioning"
state_prefix="${SHA:0:7}"
./sandboxctl create -p "${{ secrets.E2E_PROJECT_ID }}" --terraform-prefix "${state_prefix}" \
-n "cloudops-sandbox-${state_prefix}" -l "${{ env.cluster_location }}" --skip-asm -v
- name: Clean up deployment
env:
SHA: ${{ github.sha }}
run: |-
cd "${{ github.workspace }}/provisioning"
state_prefix="${SHA:0:7}"
./sandboxctl delete -p "${{ secrets.E2E_PROJECT_ID }}" --terraform-prefix "${state_prefix}" \
-n "cloudops-sandbox-${state_prefix}" -l "${{ env.cluster_location }}" --skip-asm -v