Skip to content

Commit

Permalink
Add body_file input
Browse files Browse the repository at this point in the history
Allows to use a custom file as PR body
Addresses #136
  • Loading branch information
ChristophShyper committed Nov 3, 2023
1 parent 1c1a99e commit 0545a40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
phony: help

# Release tag for the action
VERSION := v0.5.5
VERSION := v0.6.0

# GitHub Actions bogus variables
GITHUB_REF ?= refs/heads/null
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
description: Pull request body
required: false
default: ""
body_file:
description: File to be used as pull request body
required: false
default: ""
reviewer:
description: Reviewer's username
required: false
Expand Down Expand Up @@ -69,7 +73,7 @@ outputs:
description: Pull request URL.
runs:
using: docker
image: docker://devopsinfra/action-pull-request:v0.5.5
image: docker://devopsinfra/action-pull-request:v0.6.0
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
branding:
Expand Down
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ echo " target_branch: ${INPUT_TARGET_BRANCH}"
echo " title: ${INPUT_TITLE}"
echo " template: ${INPUT_TEMPLATE}"
echo " body: ${INPUT_BODY}"
echo " body_file: ${INPUT_BODY_FILE}"
echo " reviewer: ${INPUT_REVIEWER}"
echo " assignee: ${INPUT_ASSIGNEE}"
echo " label: ${INPUT_LABEL}"
Expand Down Expand Up @@ -174,7 +175,11 @@ if [[ -z "${PR_NUMBER}" ]]; then
PR_NUMBER=$(gh pr view --json number -q .number "${URL}")
else
echo -e "\nUpdating pull request"
COMMAND="hub api --method PATCH repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER} --field 'body=@/tmp/template'"
if [[ -z "${INPUT_BODY_FILE}" ]]; then
COMMAND="hub api --method PATCH repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER} --field 'body=@/tmp/template'"
else
COMMAND="hub api --method PATCH repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER} --field 'body=@${INPUT_BODY_FILE}'"
fi
echo -e "Running: ${COMMAND}"
URL=$(sh -c "${COMMAND} | jq -r '.html_url'")
# shellcheck disable=SC2181
Expand Down

0 comments on commit 0545a40

Please sign in to comment.