github.com/shashidharatd/test-infra@v0.0.0-20171006011030-71304e1ca560/mungegithub/mungers/publish_scripts/push.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2017 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  # This script sets up the .netrc file with the supplied token, then pushes to
    18  # the remote repo.
    19  # The script assumes that the working directory is the root of the repo.
    20  
    21  set -o errexit
    22  set -o nounset
    23  set -o pipefail
    24  
    25  if [ ! $# -eq 2 ]; then
    26      echo "usage: $0 token branch"
    27      exit 1
    28  fi
    29  
    30  TOKEN="${1}"
    31  BRANCH="${2}"
    32  readonly TOKEN BRANCH
    33  
    34  SCRIPT_DIR=$(dirname "${BASH_SOURCE}")
    35  source "${SCRIPT_DIR}"/util.sh
    36  
    37  set_github_token "${TOKEN}"
    38  trap cleanup_github_token EXIT SIGINT
    39  
    40  git push origin "${BRANCH}"