Rename tiltaksgjennomforing -> gjennomforing i api-db #35
Workflow file for this run
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: "BigQuery Terraform" | |
on: | |
push: | |
paths: | |
- .github/workflows/bigquery-terraform.yaml | |
- iac/bigquery-terraform/** | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: Environment | |
required: true | |
default: dev | |
options: | |
- dev | |
- dev_and_prod | |
env: | |
DEV_DIR: "iac/bigquery-terraform/dev" | |
PROD_DIR: "iac/bigquery-terraform/prod" | |
jobs: | |
terraform-plan-dev: | |
name: "terraform plan dev-gcp" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ${{ env.DEV_DIR }} | |
permissions: | |
contents: read | |
id-token: write # Required for Workload Identity Federation | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/932652929200/locations/global/workloadIdentityPools/github/providers/github-action | |
service_account: [email protected] | |
- name: Run 'terraform setup' | |
uses: hashicorp/setup-terraform@v3 | |
- run: terraform init | |
- run: terraform fmt -check | |
- run: terraform validate | |
- run: terraform plan | |
terraform-plan-prod: | |
name: "terraform plan prod-gcp" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ${{ env.PROD_DIR }} | |
permissions: | |
contents: read | |
id-token: write # Required for Workload Identity Federation | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/380520190028/locations/global/workloadIdentityPools/github/providers/github-action | |
service_account: [email protected] | |
- name: Run 'terraform setup' | |
uses: hashicorp/setup-terraform@v3 | |
- run: terraform init | |
- run: terraform fmt -check | |
- run: terraform validate | |
- run: terraform plan | |
ci: | |
name: "CI" | |
runs-on: ubuntu-latest | |
needs: [terraform-plan-dev, terraform-plan-prod] | |
steps: | |
- name: "Report success" | |
run: echo "Terraform plan succeded" | |
terraform-apply-dev: | |
needs: [ci] | |
if: github.event_name == 'push' && github.ref_name == 'main' || github.event_name == 'workflow_dispatch' | |
name: "terraform apply dev-gcp" | |
runs-on: ubuntu-latest | |
concurrency: terraform-apply-dev | |
defaults: | |
run: | |
working-directory: ${{ env.DEV_DIR }} | |
permissions: | |
contents: read | |
id-token: write # Required for Workload Identity Federation | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/932652929200/locations/global/workloadIdentityPools/github/providers/github-action | |
service_account: [email protected] | |
- name: Run 'terraform setup' | |
uses: hashicorp/setup-terraform@v3 | |
- run: terraform init | |
- run: terraform apply -auto-approve | |
terraform-apply-prod: | |
needs: [ci] | |
if: github.event_name == 'push' && github.ref_name == 'main' || github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'dev_and_prod' | |
name: "terraform apply prod-gcp" | |
runs-on: ubuntu-latest | |
concurrency: terraform-apply-prod | |
defaults: | |
run: | |
working-directory: ${{ env.PROD_DIR }} | |
permissions: | |
contents: read | |
id-token: write # Required for Workload Identity Federation | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/380520190028/locations/global/workloadIdentityPools/github/providers/github-action | |
service_account: [email protected] | |
- name: Run 'terraform setup' | |
uses: hashicorp/setup-terraform@v3 | |
- run: terraform init | |
- run: terraform apply -auto-approve |