diff --git a/actions/gapic/action.yml b/actions/gapic/action.yml index 2443726..dbebd87 100644 --- a/actions/gapic/action.yml +++ b/actions/gapic/action.yml @@ -36,6 +36,10 @@ inputs: dry_run: description: "Do not push changes" required: false + upstream: + description: Default branch of repository + default: master + required: false runs: using: "docker" image: "Dockerfile" diff --git a/actions/gapic/entrypoint.sh b/actions/gapic/entrypoint.sh index d8eb752..40204fe 100755 --- a/actions/gapic/entrypoint.sh +++ b/actions/gapic/entrypoint.sh @@ -7,7 +7,7 @@ TARGET_DIR=$(echo $INPUT_TARGET | sed 's/:/\//g' | sed 's/^\/*//g') TARGET_OUTPUT="${TARGET_DIR}.tar.gz" SLUG=$(echo $INPUT_TARGET | sed 's/^\/*//g' | sed 's/[\/.:]/_/g') BRANCH="__gapic_action__/${SLUG}" - +UPSTREAM="$INPUT_UPSTREAM"; TEMP_GIT_GOOGLEAPIS=$(mktemp -d) TEMP_GIT_LOCAL=$(mktemp -d) GOOGLE_APPLICATION_CREDENTIALS=$(mktemp) @@ -16,7 +16,7 @@ GOOGLE_APPLICATION_CREDENTIALS=$(mktemp) pushd $TEMP_GIT_GOOGLEAPIS -git clone --single-branch --branch master https://github.com/googleapis/googleapis.git . +git clone --single-branch --branch "$UPSTREAM" https://github.com/googleapis/googleapis.git . set +x # WARNING: do not remove if [[ -n "${INPUT_CACHE_SERVICE_ACCOUNT}" ]]; then @@ -41,16 +41,16 @@ git config --global user.name $INPUT_GIT_NAME git checkout -B $BRANCH # reset since this may run in cron -git reset --hard origin/master +git reset --hard "origin/$UPSTREAM" # extract the tar to the correct location tar xf "${TEMP_GIT_GOOGLEAPIS}/bazel-bin/${TARGET_OUTPUT}" --strip-components $INPUT_TAR_STRIP_COMPONENTS $INPUT_TAR_PATH #### PUBLISH COMMITS #### -[[ -n $(git diff "origin/master") ]] && differs_from_master=1 || differs_from_master=0 +[[ -n $(git diff "origin/$UPSTREAM") ]] && differs_from_upstream=1 || differs_from_upstream=0 -if [ $differs_from_master ]; then +if [ $differs_from_upstream ]; then set -x git add -A @@ -76,7 +76,7 @@ if [ $differs_from_master ]; then -H "Authorization: Bearer ${INPUT_GITHUB_TOKEN}" \ -H "Content-Type:application/json" \ -X POST https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls \ - -d "{\"title\":\"GAPIC Client Update: ${INPUT_TARGET}\", \"body\": \"\", \"head\": \"$BRANCH\", \"base\": \"master\"}" + -d "{\"title\":\"GAPIC Client Update: ${INPUT_TARGET}\", \"body\": \"\", \"head\": \"$BRANCH\", \"base\": \"$UPSTREAM\"}" fi fi