-
Notifications
You must be signed in to change notification settings - Fork 5
61 lines (45 loc) · 1.86 KB
/
gcloud-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
# more details this workflow and other at https://github.com/didier-durand/gcloud-tests
name: Cloud Build for Docker image
on:
workflow_dispatch:
inputs:
push:
#protection to avoid triggering when other workflow is modified
paths:
- '!.github/workflows/**'
- '.github/workflows/gcloud-build.yml'
schedule:
- cron: '30 2 * * MON'
env:
GCP_VERBOSITY: warning
GCR_IMAGE: test-alpine
GCB_DIR: cloud-build-dir
jobs:
build-on-Google-Cloud-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Get gcloud version & info
run: |-
echo '--- gcloud version ---'
gcloud version
echo '--- gcloud info ---'
gcloud info --anonymize
- name: Build image
run: |-
gcloud builds submit $GCB_DIR --tag="gcr.io/${{ secrets.GCP_PROJECT }}/$GCR_IMAGE:$GITHUB_SHA" --timeout=5m --verbosity=$GCP_VERBOSITY --project=${{ secrets.GCP_PROJECT }} --quiet
- name: List builds
run: |-
gcloud builds list --limit=3 --verbosity=$GCP_VERBOSITY --project=${{ secrets.GCP_PROJECT }} --quiet
- name: Describe last build
run: |-
#just obtain the build id in text format
export BUILD_ID=$(gcloud builds list --limit=1 --format="value(id)" --verbosity=$GCP_VERBOSITY --project=${{ secrets.GCP_PROJECT }} --quiet)
gcloud builds describe $BUILD_ID --verbosity=$GCP_VERBOSITY --project=${{ secrets.GCP_PROJECT }} --quiet
grep "$BUILD_ID" <<< $(gcloud builds describe $BUILD_ID --verbosity=$GCP_VERBOSITY --project=${{ secrets.GCP_PROJECT }} --quiet)