Skip to content

Commit

Permalink
feat: add support for main branch to gapic action (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoehnelt authored Jan 8, 2021
1 parent 127ce37 commit 3ce0899
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions actions/gapic/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 6 additions & 6 deletions actions/gapic/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3ce0899

Please sign in to comment.