Include terraform in action #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 |