Skip to content

Instantly share code, notes, and snippets.

@r4rohan
Last active February 20, 2024 11:01
Show Gist options
  • Save r4rohan/e15d162db16a7e3bc7bc42342eab234f to your computer and use it in GitHub Desktop.
Save r4rohan/e15d162db16a7e3bc7bc42342eab234f to your computer and use it in GitHub Desktop.
Build Config in YAML file for Google Cloud Build.
## This is for dependent pipeline, due to names it would be appearing below plan file.
steps:
- id: 'Pre Trigger Status Message'
name: 'alpine/curl'
entrypoint: sh
args:
- -c
- |
curl -X POST -H 'Content-type: application/json' --data '{"channel":"${_CHANNEL_ID}","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"Build Started for *$TRIGGER_NAME*"}}]}' "${_SLACK_WEBHOOK}"
- id: 'Download Terraform Artifact from JFrog'
name: 'releases-docker.jfrog.io/jfrog/jfrog-cli'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['curl', '-H', '${_JFROG_API}', '-XGET', '${_JFROG_ARTIFACTORY_URL}/tf/tf_plan', '--output', 'tf_plan']
- id: 'Terraform Init'
name: 'hashicorp/terraform:1.0.0'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['init']
- id: 'Terraform Apply'
name: 'hashicorp/terraform:1.0.0'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['apply', 'tf_plan']
- id: 'Delete Terraform Artifact from JFrog'
name: 'releases-docker.jfrog.io/jfrog/jfrog-cli'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['curl', '-H', '${_JFROG_API}', '-XDELETE', '${_JFROG_ARTIFACTORY_URL}/tf/tf_plan']
## This is for first pipeline, due to names it would be appearing after apply file.
steps:
- id: 'Terraform Initialize'
name: 'hashicorp/terraform:1.0.0'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['init']
- id: 'Terraform Format'
name: 'hashicorp/terraform:1.0.0'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['fmt', '-recursive', '-check', '-diff']
- id: 'Terraform Validate'
name: 'hashicorp/terraform:1.0.0'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['validate']
- id: 'Terraform Plan with output file'
name: 'hashicorp/terraform:1.0.0'
dir: 'scripts/manual-approvals-cloudbuild/gce-tf'
args: ['plan', '-out=tf_plan']
- id: 'Push Terraform Output file to JFrog Artifactory'
name: 'releases-docker.jfrog.io/jfrog/jfrog-cli'
dir: 'scripts/cloudbuild/gce-tf'
args: ['curl', '-H', '${_JFROG_API}', '-T', 'tf_plan', '${_JFROG_ARTIFACTORY_URL}/tf/tf_plan']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment