-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (55 loc) · 2.09 KB
/
rsp-demo-firestore-proj-tf.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Deploys Science Platform Integration GCP Project with Terraform
name: 'RSP DEMO FIRESTORE GCP Project'
on:
workflow_dispatch
# pull_request:
# paths:
# - 'environment/deployments/science-platform/firestore/env/demo.tfvars'
# push:
# paths:
# - 'environment/deployments/science-platform/firestore/env/demo.tfvars'
# branches:
# - main
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
# Sets default shell and working directory
defaults:
run:
shell: bash
working-directory: ./environment/deployments/science-platform/firestore
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v3
# Gcloud CLI setup
- name: GCP login
uses: google-github-actions/setup-gcloud@v0
with:
version: '379.0.0'
service_account_key: ${{ secrets.GOOGLE_CREDENTIALS }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
export_default_credentials: true
# Install terraform
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.13.5
# Checks for proper terraform code formatting
- name: Terraform Fmt
run: terraform fmt
# Initialize a new or existing terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init -backend-config=bucket=${{ secrets.TERRAFORM_STATE_BUCKET }} -backend-config=prefix=science-platform/firestore/demo
# Checks that all terraform configuration files adhere to a canonical format
- name: Terraform Validate
run: terraform validate
# Generates Terraform execution plan
- name: Terraform Plan
id: plan
run: terraform plan -var-file=env/demo.tfvars -no-color
# On push to main, build or change infrastructure according to terraform configuration files
- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -var-file=env/demo.tfvars -auto-approve