-
Notifications
You must be signed in to change notification settings - Fork 31
98 lines (81 loc) · 2.93 KB
/
terraform.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Terraform
on:
pull_request:
branches:
- "*"
push:
branches:
- main
workflow_dispatch:
inputs:
monitor_permissions:
type: boolean
description: Monitor Permissions
required: false
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Google Cloud
runs-on: ubuntu-latest
env:
GRADLE_OPTS: "-Dorg.gradle.logging.level=${{ github.event.inputs.log_level || 'info' }}"
permissions:
pull-requests: 'write'
id-token: write
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
if: ${{ github.event.inputs.monitor_permissions == 'true' }}
- uses: actions/checkout@v4
- id: setup-cloud
uses: ./.github/actions/setup-cloud
with:
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }}
token_format: access_token
- uses: ./.github/actions/setup-gradle
if: ${{ github.ref == 'refs/heads/main' }}
- if: ${{ github.ref == 'refs/heads/main' }}
run: >
./gradlew cloud-run:jib
--image=europe-west1-docker.pkg.dev/${{ steps.setup-cloud.outputs.project_id }}/cloud-run-source-deploy/api.ashdavies.dev
--no-configuration-cache
--console=plain
# env:
# FIREBASE_ANDROID_APP_ID: ${{ secrets.firebase_android_app_id }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GOOGLE_SERVICE_ACCOUNT_ID: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }}
- id: token
uses: tibdex/github-app-token@v2
with:
private_key: ${{ secrets.PRIVATE_KEY }}
app_id: ${{ secrets.APP_ID }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.10.2
- id: init
run: terraform -chdir=terraform init
- id: plan
env:
TF_VAR_gh_token: ${{ steps.token.outputs.token }}
TF_LOG: ${{ inputs.debug && 'DEBUG' || 'ERROR' }}
TF_INPUT: false
if: ${{ github.event_name == 'pull_request' }}
run: |
terraform -chdir=terraform plan >/dev/null -lock-timeout=5m -out=.terraform/terraform.tfplan
terraform -chdir=terraform show .terraform/terraform.tfplan -no-color
- uses: thollander/actions-comment-pull-request@v3
if: ${{ github.event_name == 'pull_request' }}
with:
message: "```${{ steps.plan.outputs.stdout }}```"
comment-tag: terraform-plan
mode: recreate
- id: apply
env:
TF_LOG: ${{ inputs.debug && 'DEBUG' || 'ERROR' }}
TF_VAR_gh_token: ${{ steps.token.outputs.token }}
TF_INPUT: false
if: ${{ github.ref == 'refs/heads/main' }}
run: terraform -chdir=terraform apply -auto-approve -lock-timeout=5m