Skip to content

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

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

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

---
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:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- 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
- name: DEBUG
shell: bash
run: |
echo $PATH
ls -la /home/runner
ls -la /home/runner/_work/_tool/
test-terraform-apply:
needs: build-terraform-file
runs-on: ghr-proxmox-vm-sthings-cicd
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- 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:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- 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