generated from kedacore/github-template
-
Notifications
You must be signed in to change notification settings - Fork 7
73 lines (61 loc) · 2.19 KB
/
main.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
67
68
69
70
71
72
73
name: "Deploy infrastucture"
on:
push:
branches:
- main
paths:
- "**.tf"
- ".github/workflows/terraform.yaml"
schedule: # Scheduling the job we will update AKS automatically
- cron: "0 7 * * 1" # Mondays at 7:00 AM
workflow_dispatch:
concurrency: terraform
permissions:
id-token: write
contents: read
jobs:
terraform:
name: "Terraform"
runs-on: ubuntu-latest
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_USE_OIDC: true
GITHUB_TOKEN: ${{ secrets.GH_AUTOMATION_PAT }}
GITHUB_OWNER: kedacore
GRAFANA_CLOUD_API_KEY: ${{ secrets.GRAFANA_CLOUD_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into Azure using OIDC
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Log into AWS using OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-2
- name: Log into GCP using OIDC
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Setup Terraform
uses: hashicorp/[email protected]
- name: Terraform Init
run: |
terraform init \
-backend-config=storage_account_name=${{ secrets.BACKEND_STORAGE_ACCOUNT_NAME}} \
-backend-config=container_name=${{ secrets.BACKEND_STORAGE_CONTAINER_NAME}} \
-backend-config=resource_group_name=${{ secrets.BACKEND_STORAGE_RESOURCE_GROUP_NAME}}
working-directory: terraform
- name: Terraform Plan
run: terraform plan -out=plan.tfplan
working-directory: terraform
- name: Terraform Apply
run: terraform apply -input=false -auto-approve plan.tfplan
working-directory: terraform