agones.dev/agones@v1.54.0/build/always/always-be-building.yaml (about) 1 --- 2 # Copyright 2023 Google LLC All Rights Reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # Always Be Building 16 # 17 # A build that checks to see if there are any CI builds running, and if there 18 # are not, starts a build of `main`. 19 # 20 # Triggered by Cloud Scheduler at some arbitrary interval, e.g. 2h 21 steps: 22 - name: gcr.io/cloud-builders/gcloud 23 id: always-be-building 24 script: | 25 #!/usr/bin/env bash 26 set -e 27 set -o pipefail 28 echo "== Checking for active builds ==" 29 gcloud builds list --filter "status=WORKING AND tags='ci'" --format="value(id,startTime)" |& tee /tmp/active_builds 30 if [[ `wc -l < /tmp/active_builds` != 0 ]]; then 31 echo "== Builds already running, doing nothing ==" 32 exit 0 33 fi 34 echo "== Build queue empty, starting `main` build ==" 35 gcloud builds triggers run 709790cf-29e1-4350-9407-de7cb5b1dc9e --branch=main 36 tags: [always-be-building] 37 timeout: 300s # generous time in case builds take a while to list