-
Notifications
You must be signed in to change notification settings - Fork 46
58 lines (55 loc) · 2.09 KB
/
trigger-cloudbuild.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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)"