Update setup-runner.yml #1
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 Deploy Workflow | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| terraform: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the code | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| # Setup Terraform | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v2 | |
| with: | |
| terraform_version: 1.9.8 | |
| # Initialize Terraform | |
| - name: Terraform Init | |
| run: terraform init | |
| # Plan Terraform changes | |
| - name: Terraform Plan | |
| run: terraform plan -out=tfplan | |
| # Apply Terraform changes | |
| - name: Terraform Apply | |
| if: github.ref == 'refs/heads/main' | |
| run: terraform apply -auto-approve tfplan | |
| # Destroy infrastructure (optional step, typically used for PRs) | |
| - name: Terraform Destroy | |
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
| run: terraform destroy -auto-approve | |
| # Securely pass variables for sensitive information | |
| - name: Set Environment Variables | |
| run: | | |
| echo "TF_VAR_linux_host=${{ secrets.LINUX_HOST }}" >> $GITHUB_ENV | |
| echo "TF_VAR_linux_user=${{ secrets.LINUX_USER }}" >> $GITHUB_ENV | |
| echo "TF_VAR_linux_password=${{ secrets.LINUX_PASSWORD }}" >> $GITHUB_ENV | |
| echo "TF_VAR_linux_port=${{ secrets.LINUX_PORT }}" >> $GITHUB_ENV |