Fix Pipeline Builds #31
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: Infra Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
terraform-release: | |
permissions: | |
contents: read | |
issues: read | |
checks: write | |
pull-requests: write | |
id-token: 'write' | |
name: "Terraform Release" | |
runs-on: ubuntu-latest | |
environment: Dev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Terraform | |
env: | |
TERRAFORM_VERSION: "1.7.4" | |
run: | | |
tf_version=$TERRAFORM_VERSION | |
wget https://releases.hashicorp.com/terraform/"$tf_version"/terraform_"$tf_version"_linux_amd64.zip | |
# Check if the terraform directory exists before deleting | |
if [ -d "/usr/local/bin/terraform" ]; then | |
sudo rm -rf /usr/local/bin/terraform | |
fi | |
# Check if the extracted directory exists before deleting | |
if [ -d "terraform_"$tf_version"_linux_amd64" ]; then | |
sudo rm -rf terraform_"$tf_version"_linux_amd64 | |
fi | |
sudo unzip -o terraform_"$tf_version"_linux_amd64.zip -d terraform_install | |
sudo mv terraform_install/terraform /usr/local/bin/ | |
- name: Verify Terraform version | |
run: terraform --version | |
# https://github.com/google-github-actions/auth | |
- name: Authenticate with Google Cloud | |
uses: 'google-github-actions/auth@v2' | |
with: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITYPROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT }} | |
- name: Terraform Plan | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
chmod +x ci/scripts/*.sh | |
ci/scripts/generate_tfvars.sh terraform/environments/dev ${{ secrets.PROJECT_ID }} dev | |
python3 ci/scripts/execute-terraform.py --config ci/configs/pipeline-config.json --command plan --env dev | |
- name: Terraform Apply | |
if: ${{ github.event_name != 'pull_request' }} | |
run: | | |
chmod +x ci/scripts/*.sh | |
python3 ci/scripts/execute-terraform.py --config ci/configs/pipeline-config.json --command apply --env dev |