forked from finos/legend-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (51 loc) · 2.62 KB
/
trigger-gcp-build.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
59
60
61
62
63
64
65
66
# Copyright 2022 Goldman Sachs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Trigger GCP build
env:
GCP_API_KEY: ${{ secrets.GCP_API_KEY }}
GCP_BUILD_TRIGGER_SECRET: ${{ secrets.GCP_BUILD_TRIGGER_SECRET }}
GCP_REGION: us-east1
on:
workflow_dispatch: {}
jobs:
trigger-build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Trigger GCP build
run: curl -X POST -H "application/json" "https://cloudbuild.googleapis.com/v1/projects/legend-integration-testing/triggers/legend-engine-build-webhook:webhook?key=${GCP_API_KEY}&secret=${GCP_BUILD_TRIGGER_SECRET}" -d "{}"
- name: GCP auth
uses: google-github-actions/auth@v0
with:
workload_identity_provider: 'projects/412074507462/locations/global/workloadIdentityPools/finos-legend-engine-build-pool/providers/finos-legend-engine-provider'
service_account: 'finos-legend-engine-build@legend-integration-testing.iam.gserviceaccount.com'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: Get last build ID
run: echo "GCP_BUILD_ID=$(gcloud builds list --region="${GCP_REGION}" --filter substitutions.TRIGGER_NAME='legend-engine-build-webhook' --sort-by create_time --format='value(id)' | tail -n 1)" >> $GITHUB_ENV
- name: Stream build logs
run: gcloud builds log --region="${GCP_REGION}" --stream '${{ env.GCP_BUILD_ID }}'
- name: Report GCP build status
run: |
buildStatus=$(gcloud builds list --region="${GCP_REGION}" --filter id='${{ env.GCP_BUILD_ID }}' --format='value(status)')
echo "Logs streaming ended with the build having a status of '${buildStatus}'"
echo "Check the full build logs at: https://storage.googleapis.com/finos-legend-engine-logs/log-${{ env.GCP_BUILD_ID }}.txt"
echo "All GCP build logs are available here: https://console.cloud.google.com/storage/browser/finos-legend-engine-logs"
if [ $buildStatus != "SUCCESS" ]; then
exit 1
fi