Skip to content

Merge pull request #9 from stuttgart-things/feature/issue-1/vmTest-pi… #12

Merge pull request #9 from stuttgart-things/feature/issue-1/vmTest-pi…

Merge pull request #9 from stuttgart-things/feature/issue-1/vmTest-pi… #12

---
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/checkout@v4.1.1
- 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/checkout@v4.1.1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.7.0"
- 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/checkout@v4.1.1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.7.0"
- 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