Deploy a workflow from Git using Cloud Build

Create a Cloud Build configuration file that deploys and runs a workflow.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample


# Deploy the test workflow with the commit sha
- id: 'deploy-test-workflow'
  name: ''
  args: ['workflows', 'deploy', '$_WORKFLOW_NAME-$BRANCH_NAME-$SHORT_SHA', '--source', 'gitops/workflow.yaml']

# Run the test workflow and capture the output
- id: 'run-test-workflow'
  name: ''
  entrypoint: 'bash'
  args: ['-c', 'gcloud workflows run $_WORKFLOW_NAME-$BRANCH_NAME-$SHORT_SHA > /workspace/testoutput.log']

# Delete the test workflow
- id: 'delete-test-workflow'
  name: ''
  args: ['workflows', 'delete', '$_WORKFLOW_NAME-$BRANCH_NAME-$SHORT_SHA', '--quiet']

# Check the test output
- id: 'check-test-workflow'
  name: ''
  entrypoint: 'bash'
  args: ['gitops/test-$']

# Deploy the workflow
- id: 'deploy-workflow'
  name: ''
  args: ['workflows', 'deploy', '$_WORKFLOW_NAME-$BRANCH_NAME', '--source', 'gitops/workflow.yaml']

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.