-
Notifications
You must be signed in to change notification settings - Fork 3
116 lines (103 loc) · 3.64 KB
/
ci-plan-infra.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Infra - Plan
on:
workflow_call:
inputs:
version:
description: 'The image version to use in the ECS task definition'
type: string
default: 'latest'
stage:
description: 'The environment to plan against'
type: string
required: true
stage-url:
description: 'The URL of the environment'
type: string
required: true
grafana-workspace-name:
description: 'The name of the Grafana workspace for the monitoring deployment'
type: string
default: ${{ vars.GRAFANA_WORKSPACE_NAME }}
tf-directory:
description: 'The directory containing the Terraform files'
type: string
default: ${{ vars.TF_DIRECTORY }}
tf-variables:
description: 'The values of the dynamic Terraform variables'
type: string
default: ''
aws-region:
description: 'The AWS region to deploy to'
type: string
default: ${{ vars.AWS_REGION }}
aws-role-monitoring-arn:
description: 'The ARN of the AWS role to assume for the monitoring deployment'
type: string
default: ${{ vars.AWS_ROLE_MONITORING }}
run-label:
description: 'The run label to use for the actions'
type: string
default: 'ubuntu-latest'
secrets:
TF_API_TOKEN:
required: true
permissions:
contents: read
id-token: write
concurrency: deploy-${{ inputs.stage }}
env:
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}
TF_WORKSPACE: wl-${{ inputs.stage }}
jobs:
plan:
name: Plan `${{ inputs.stage }}`
runs-on: ${{ inputs.run-label }}
environment:
name: ${{ inputs.stage }}
url: ${{ inputs.stage-url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
- name: Configure AWS Credentials for Monitoring account
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.aws-role-monitoring-arn }}
aws-region: ${{ inputs.aws-region }}
- name: Create Grafana key
id: grafana-get-key
uses: WalletConnect/ci_workflows/.github/actions/grafana-key@main
with:
workspace-name: ${{ inputs.grafana-workspace-name }}
key-prefix: ${{ github.event.repository.name }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Cache Terraform data
uses: actions/cache@v4
with:
path: ${{ inputs.tf-directory }}/.terraform
key: terraform-${{ hashFiles('${{ inputs.tf-directory }}/.terraform.lock.hcl') }}
- name: Init Terraform
working-directory: ${{ inputs.tf-directory }}
run: terraform init -no-color
- name: Configure Terraform Variables
uses: WalletConnect/ci_workflows/.github/actions/tf-vars@main
with:
infra-directory: ${{ inputs.tf-directory }}
variables: |
image_version:${{ inputs.version }}
grafana_auth:${{ steps.grafana-get-key.outputs.key }}
${{ inputs.tf-variables }}
- name: Plan ${{ inputs.stage }}
working-directory: ${{ inputs.tf-directory }}
run: terraform plan -no-color
- name: Delete Grafana key
if: ${{ always() }}
uses: WalletConnect/actions/aws/grafana/delete-key/@2.5.3
with:
workspace-id: ${{ steps.grafana-get-key.outputs.workspace-id }}
key-name: ${{ steps.grafana-get-key.outputs.key-name }}