Terraform CI/CD Pipeline #44
This file contains hidden or 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 CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_run: | |
| workflows: [Build Infrastructure] | |
| types: [completed] | |
| jobs: | |
| terraform: | |
| #runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: self-hosted | |
| container: | |
| image: ghcr.io/catthehacker/ubuntu:act-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set environment variables from GitHub Secrets | |
| run: | | |
| echo "VCENTER_USER=${{ secrets.VCENTER_USER }}" >> $GITHUB_ENV | |
| echo "VCENTER_PASSWORD=${{ secrets.VCENTER_PASSWORD }}" >> $GITHUB_ENV | |
| echo "VCENTER_SERVER=${{ secrets.VCENTER_SERVER }}" >> $GITHUB_ENV | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@v2 | |
| with: | |
| terraform_version: 'latest' | |
| - run: pwd | |
| - name: Initialize Terraform | |
| run: | | |
| terraform init | |
| - name: Terraform Plan | |
| run: | | |
| terraform plan | |
| - name: Apply Terraform Configuration | |
| run: | | |
| terraform apply -auto-approve |