-
Notifications
You must be signed in to change notification settings - Fork 5
130 lines (120 loc) · 4.26 KB
/
terraform-apply.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Run terraform
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- terraform-plans/**
- .github/workflows/terraform-apply.yaml
push:
branches:
- main
paths:
- terraform-plans/**
- .github/workflows/terraform-apply.yaml
jobs:
lint:
name: Linters
runs-on: ubuntu-22.04
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Install Terraform
run: sudo snap install terraform --classic
# To format the repository to pass this lint:
# $ cd terraform-plans && terraform fmt -recursive
- name: Terraform format lint
working-directory: ./terraform-plans
run: terraform fmt -check -recursive -diff
terraform:
name: Run Terraform
needs:
- lint
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
repository:
# The naming convention of the files is $REPO_$BRANCH.tfvars
- bootstack-actions_main
- charm-advanced-routing_main
- charm-apt-mirror_main
- charm-cloudsupport_main
- charm-duplicity_main
- charm-juju-backup-all_main
- charm-juju-local_main
- charm-local-users_main
- charm-logrotated_main
- charm-nginx_main
- charm-nrpe_main
- charm-openstack-service-checks_main
- charm-prometheus-blackbox-exporter_main
- charm-prometheus-juju-exporter_main
- charm-prometheus-libvirt-exporter_main
- charm-simple-streams_main
- charm-storage-connector_main
- charm-sysconfig_main
- charm-userdir-ldap_main
- charmed-openstack-exporter-snap_main
- charmed-openstack-upgrader_main
- hardware-observer-operator_main
- juju-backup-all_main
- juju-lint_main
- layer-beats-base_main
- layer-filebeat_main
- openstack-exporter-operator_main
- prometheus-hardware-exporter_main
- prometheus-juju-backup-all-exporter_main
- prometheus-juju-exporter_main
- prometheus-openstack-exporter_main
- smartctl-exporter-snap_main
- snap-tempest-automation_main
- snap-tempest_main
- snap-tempest_stable_antelope
- snap-tempest_stable_bobcat
- snap-tempest_stable_caracal
- snap-tempest_stable_ussuri
- snap-tempest_stable_victoria
- snap-tempest_stable_wallaby
- snap-tempest_stable_xena
- snap-tempest_stable_yoga
- snap-tempest_stable_zed
- solutions-engineering-automation_main
- tailscale-snap_main
- dcgm-snap_main
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Install Terraform
run: sudo snap install terraform --classic
- name: Terraform init
working-directory: ./terraform-plans
run: terraform init
- name: Terraform validate
working-directory: ./terraform-plans
env:
GITHUB_APP_ID: ${{ secrets.SOLENG_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets.SOLENG_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.SOLENG_APP_PEM_FILE }}
run: terraform validate -no-color
- name: Terraform plan
working-directory: ./terraform-plans
env:
GITHUB_APP_ID: ${{ secrets.SOLENG_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets.SOLENG_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.SOLENG_APP_PEM_FILE }}
run: |
terraform plan -no-color \
-var-file=configs/github.tfvars \
-var-file=configs/${{ matrix.repository }}.tfvars \
-out ./tf.plan
- name: Terraform apply (if running from main branch)
if: ${{ github.ref_name == 'main' }}
working-directory: ./terraform-plans
env:
GITHUB_APP_ID: ${{ secrets.SOLENG_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets.SOLENG_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.SOLENG_APP_PEM_FILE }}
run: |
terraform apply ./tf.plan -no-color