2021-12-21 19:40:30 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright 2021 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
2022-01-11 00:16:14 +03:00
|
|
|
# Deploy the vuln worker to Cloud Run, using Cloud Build.
|
2021-12-21 19:40:30 +03:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
source devtools/lib.sh || { echo "Are you at repo root?"; exit 1; }
|
|
|
|
|
|
|
|
# Report whether the current repo's workspace has no uncommitted files.
|
|
|
|
clean_workspace() {
|
|
|
|
[[ $(git status --porcelain) == '' ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
local prefix=
|
|
|
|
if [[ $1 = '-n' ]]; then
|
|
|
|
prefix='echo dryrun: '
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
local env=$1
|
|
|
|
|
|
|
|
case $env in
|
|
|
|
dev|prod);;
|
|
|
|
*)
|
|
|
|
die "usage: $0 [-n] (dev | prod)"
|
|
|
|
esac
|
|
|
|
|
|
|
|
local project=$(tfvar ${env}_project)
|
2022-01-11 00:16:14 +03:00
|
|
|
local commit=$(git rev-parse --short HEAD)
|
|
|
|
local unclean
|
|
|
|
if ! clean_workspace; then
|
|
|
|
unclean="-unclean"
|
2022-01-09 16:02:54 +03:00
|
|
|
fi
|
2022-01-11 00:16:14 +03:00
|
|
|
|
|
|
|
$prefix gcloud builds submit \
|
|
|
|
--project $project \
|
|
|
|
--config deploy/worker.yaml \
|
|
|
|
--substitutions SHORT_SHA=${commit}${unclean},_ENV=$env
|
2021-12-21 19:40:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
main $@
|