Skip to content

chore: Update Terraform workflow to use "terraform apply" instead of … #102

chore: Update Terraform workflow to use "terraform apply" instead of …

chore: Update Terraform workflow to use "terraform apply" instead of … #102

Workflow file for this run

name: Terraform Validation
on:
push:
branches:
- main # ou votre branche cible
jobs:
terraform_validation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create certificate.ovpn from GitHub Secret
run: |
echo "${{ secrets.VPN_CERTIFICATE_PROD }}" | base64 --decode > certificate.ovpn
- name: Connect to openVPN
run: |
sudo apt-get update
sudo apt-get install openvpn -y
sudo openvpn --config certificate.ovpn --daemon
echo "Connected to VPN"
- name: Wait for a VPN connection
timeout-minutes: 1
run: until ping -c1 192.168.1.1; do sleep 1; done
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.7.3
- name: Create temp_backend.tfvars from GitHub Secret
run: |
echo "${{ secrets.BACKEND_PROD }}" | base64 --decode > temp_backend.tfvars
- name: Terraform Init
run: terraform init -backend-config="temp_backend.tfvars" -reconfigure
- name: Terraform Validate
run: terraform validate
- name: Create secrets_prod.tfvars from GitHub Secret
run: |
echo "${{ secrets.SECRETS_PROD }}" | base64 --decode > secrets_prod.tfvars
- name: Terraform Plan
run: terraform plan -var-file="secrets_prod.tfvars" -var-file="configurations/prod.tfvars"
# - name: Terraform apply
# run: terraform apply -auto-approve -var-file="secrets_prod.tfvars" -var-file="configurations/prod.tfvars"
- name: Terraform destroy
run: terraform destroy -auto-approve -var-file="secrets_prod.tfvars" -var-file="configurations/prod.tfvars"