Ajouter une vérification VPN avant la validation Terraform #58
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: Terraform Validation | |
on: | |
push: | |
branches: | |
- main # ou votre branche cible | |
jobs: | |
check_vpn: | |
name: Check VPN | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create certificate.ovpn from GitHub Secret | |
run: | | |
echo "${{ secrets.VPN_CERTIFICATE_PROD }}" | base64 --decode > certificate.ovpn | |
- name: Install OpenVPN | |
run: | | |
sudo apt update | |
sudo apt install -y openvpn openvpn-systemd-resolved | |
- name: Connect to VPN | |
run: | | |
sudo openvpn --config certificate.ovpn --daemon | |
- name: Check VPN Connection | |
run: | | |
sleep 10 | |
curl --silent --fail http://ifconfig.io/ip | |
echo "VPN Connection Successful" | |
terraform_validation: | |
name: Terraform Validation | |
runs-on: ubuntu-latest | |
needs: check_vpn | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create certificate.ovpn from GitHub Secret | |
run: | | |
echo "${{ secrets.VPN_CERTIFICATE_PROD }}" | base64 --decode > certificate.ovpn | |
- name: Install OpenVPN | |
run: | | |
sudo apt update | |
sudo apt install -y openvpn openvpn-systemd-resolved | |
- name: Connect to VPN | |
run: | | |
sudo openvpn --config certificate.ovpn --daemon | |
- 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" -out=plan-output.txt |