From 90f97d7ca1993c9b01dcc08b6f1f30c720f2feee Mon Sep 17 00:00:00 2001 From: vsoch Date: Wed, 18 Mar 2020 15:35:22 -0600 Subject: [PATCH] last change to add example Signed-off-by: vsoch --- examples/assignees-example.yml | 17 +++++++++++++++++ pull-request.sh | 8 +++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 examples/assignees-example.yml diff --git a/examples/assignees-example.yml b/examples/assignees-example.yml new file mode 100644 index 0000000..6db7db3 --- /dev/null +++ b/examples/assignees-example.yml @@ -0,0 +1,17 @@ +name: Pull Request on Branch Push +on: + push: + branches-ignore: + - devel +jobs: + auto-pull-request: + name: PullRequestAction + runs-on: ubuntu-latest + steps: + - name: pull-request-action + uses: vsoch/pull-request-action@add/assignees + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_PREFIX: "update/" + PULL_REQUEST_BRANCH: "master" + PULL_REQUEST_ASSIGNEES: vsoch diff --git a/pull-request.sh b/pull-request.sh index 3518fc9..12111a7 100755 --- a/pull-request.sh +++ b/pull-request.sh @@ -37,7 +37,7 @@ check_events_json() { if [[ ! -f "${GITHUB_EVENT_PATH}" ]]; then printf "Cannot find Github events file at ${GITHUB_EVENT_PATH}\n"; - exit 1; + exit 1 fi printf "Found ${GITHUB_EVENT_PATH}\n"; @@ -80,9 +80,8 @@ create_pull_request() { NUMBER=$(echo "${RESPONSE}" | jq --raw-output '.number') printf "Number opened for PR is ${NUMBER}\n" - # Remove trailing slashes - ASSIGNEES="${ASSIGNEES%\"}" - ASSIGNEES="${ASSIGNEES#\"}" + # Remove leading and trailing quotes + ASSIGNEES=$(echo "$ASSIGNEES" | sed -e 's/^"//' -e 's/"$//') # Parse assignees into a list ASSIGNEES=$(echo $ASSIGNEES | sed -e 's/\(\w*\)/,"\1"/g' | cut -d , -f 2-) @@ -94,7 +93,6 @@ create_pull_request() { ASSIGNEES_URL="${ISSUE_URL}/${NUMBER}/assignees" curl -sSL -H "${AUTH_HEADER}" -H "${HEADER}" --user "${GITHUB_ACTOR}" -X POST --data "${DATA}" ${ASSIGNEES_URL} printf "$?\n" - exit 1; fi fi }