Cloudbuild Build & Deploy #235
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: Trigger Cloudbuild | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: [Docker CI Multi-Platform] | |
types: [completed] | |
branches: [master, staging] | |
permissions: | |
contents: read | |
jobs: | |
trigger_cloudbuild: | |
name: Trigger Cloud Build | |
if: github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# GCP credentials is a multi-line string, and will result in error when trying to set it to github env. | |
# directly use it in the auth step instead. | |
- name: Set prod envs | |
if: github.ref == 'refs/heads/master' | |
run: | | |
echo "LF_BRANCH=master" >> "$GITHUB_ENV" | |
echo "LF_CLOUDBUILD_TRIGGER=logflare-master" >> "$GITHUB_ENV" | |
echo "LF_PROJECT_ID=logflare-232118" >> "$GITHUB_ENV" | |
- name: Set staging envs | |
if: ${{ github.ref == 'refs/heads/staging' }} | |
run: | | |
echo "LF_BRANCH=staging" >> "$GITHUB_ENV" | |
echo "LF_CLOUDBUILD_TRIGGER=logflare-app-staging-trigger" >> "$GITHUB_ENV" | |
echo "LF_PROJECT_ID=logflare-staging" >> "$GITHUB_ENV" | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- if: github.ref == 'refs/heads/master' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: ${{ secrets.GCP_PROD_CREDENTIALS }} | |
create_credentials_file: true | |
export_environment_variables: true | |
cleanup_credentials: false | |
- if: github.ref == 'refs/heads/staging' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: ${{ secrets.GCP_STAGING_CREDENTIALS }} | |
create_credentials_file: true | |
export_environment_variables: true | |
cleanup_credentials: false | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v1' | |
with: | |
version: '418.0.0' | |
project_id: ${{ env.LF_PROJECT_ID}} | |
- name: 'Trigger Cloud Build' | |
run: | | |
gcloud builds triggers run ${{ env.LF_CLOUDBUILD_TRIGGER }} --branch=${{ env.LF_BRANCH }} --format "value(name)" |