diff options
author | Adin Scannell <ascannell@google.com> | 2019-09-11 18:48:26 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-09-11 18:49:53 -0700 |
commit | c06ef5131f1ccd3106ccf4fa4e787db079db2d96 (patch) | |
tree | a533473a3fdfdc6c96c85a33c85128d0ecb00074 | |
parent | f52dd451ed4c517d81dc3274568ea214fb218e71 (diff) |
Fix authorization for continuous integration.
The credentials must be explicitly refreshed for pushing to
the repository on the Go branch.
PiperOrigin-RevId: 268589817
-rw-r--r-- | kokoro/go.cfg | 14 | ||||
-rwxr-xr-x | scripts/go.sh | 9 |
2 files changed, 23 insertions, 0 deletions
diff --git a/kokoro/go.cfg b/kokoro/go.cfg index d1577252a..759e16152 100644 --- a/kokoro/go.cfg +++ b/kokoro/go.cfg @@ -1,5 +1,19 @@ build_file: "repo/scripts/go.sh" +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73898 + keyname: "kokoro-github-access-token" + } + } +} + +env_vars { + key: "KOKORO_GITHUB_ACCESS_TOKEN" + value: "$KOKORO_ROOT/src/keystore/73898_kokoro-github-access-token" +} + env_vars { key: "KOKORO_GO_PUSH" value: "true" diff --git a/scripts/go.sh b/scripts/go.sh index e49d76c6d..83a667640 100755 --- a/scripts/go.sh +++ b/scripts/go.sh @@ -30,5 +30,14 @@ go build ./... # Push, if required. if [[ "${KOKORO_GO_PUSH}" == "true" ]]; then + if [[ -v KOKORO_GITHUB_ACCESS_TOKEN ]]; then + git config --global credential.helper cache + git credential approve <<EOF +protocol=https +host=github.com +username=$(cat "${KOKORO_GITHUB_ACCESS_TOKEN}") +password=x-oauth-basic +EOF + fi git push origin go:go fi |