-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (97 loc) · 2.74 KB
/
vm-creation-terraform.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
---
name: Python
on:
push:
branches:
- main
- feature/*
- review/*
- fix/*
pull_request:
types: [opened, reopened]
env:
pve_api_url: ${{ secrets.PVE_API_URL }}
pve_api_user: ${{ secrets.PVE_API_USER }}
pve_api_password: ${{ secrets.PVE_API_PASSWORD }}
vm_ssh_user: ${{ secrets.VM_SSH_USER }}
vm_ssh_password: ${{ secrets.VM_SSH_PASSWORD }}
pve_api_tls_verify: ${{ vars.PVE_API_TLS_VERIFY }}
jobs:
build-terraform-file:
runs-on: ghr-proxmox-vm-sthings-cicd
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
env:
AGENT_TOOLSDIRECTORY: /home/runner/_work/_tool
- name: Install dependencies
run: |
python -m pip install github-action-utils PyYAML Jinja2
- name: Run Python to build main.tf from template
run: |
python3 tests/build_tf_file.py
- name: Upload main.tf file for job 2
uses: actions/upload-artifact@v4
with:
name: terraform_main
path: main.tf
test-terraform-apply:
needs: build-terraform-file
runs-on: ghr-proxmox-vm-sthings-cicd
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: hashicorp/setup-terraform@v3
- name: Install dependencies
run: |
python -m pip install github-action-utils python-terraform
- name: Download main.tf
uses: actions/download-artifact@v4
with:
name: terraform_main
- name: Run in Python Terraform Apply
run: |
python3 tests/terraform_apply.py
- name: Upload tfstate file for cleanup
if: always()
uses: actions/upload-artifact@v4
with:
name: terraform_state
path: terraform.tfstate
- name: Run in Python Terraform Destroy
run: |
python3 tests/terraform_destroy.py
cleanup:
if: ${{ always() }}
needs: test-terraform-apply
runs-on: ghr-proxmox-vm-sthings-cicd
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: hashicorp/setup-terraform@v3
- name: Install dependencies
run: |
python -m pip install github-action-utils python-terraform
- name: Download tfstate
uses: actions/download-artifact@v4
with:
name: terraform_state
- name: Download main
uses: actions/download-artifact@v4
with:
name: terraform_main
- name: Run Python Terraform Destroy
run: |
python3 tests/terraform_destroy.py