Skip to content

Commit

Permalink
Replace input check_diff with allow_no_diff
Browse files Browse the repository at this point in the history
This will allow for better understanding of underlying logic.
  • Loading branch information
ChristophShyper committed Jun 30, 2022
1 parent 7d6b6b8 commit 5dd0639
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Features:
* Can assign `assignee`, `reviewer`, one or more `label`, a `milestone` or mark it as a `draft`
* Can replace any `old_string` inside a pull request template with a `new_string`. Or put commits' subjects in place of `old_string`.
* When `get_diff` is `true` will add list of commits in place of `<!-- Diff commits -->` and list of modified files in place of `<!-- Diff files -->` in a pull request template.

* When `allow_no_diff` is set to true will continue execution and create pull request even if both branches have no differences, e.g. having only a merge commit.

## Badge swag
[![Master branch](https://github.com/devops-infra/action-pull-request/workflows/Master%20branch/badge.svg)](https://github.com/devops-infra/action-pull-request/actions?query=workflow%3A%22Master+branch%22)
Expand Down Expand Up @@ -54,16 +54,16 @@ Features:
new_string: "** Automatic pull request**"
get_diff: true
ignore_users: "dependabot"
check_diff: true
allow_no_diff: false
```


| Input Variable | Required | Default | Description |
| -------------- | -------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| github_token | Yes | `""` | GitHub token `${{ secrets.GITHUB_TOKEN }}` |
| allow_no_diff | No | `false` | Allows to continue on merge commits with no diffs. |
| assignee | No | `""` | Assignee's usernames. |
| body | No | *list of commits* | Pull request body. |
| check_diff | No | `true` | Whether to check if files differ before creating a PR. |
| draft | No | `false` | Whether to mark it as a draft. |
| get_diff | No | `false` | Whether to replace predefined comments with differences between branches - see details below. |
| ignore_users | No | `"dependabot"` | List of users to ignore, coma separated. |
Expand Down
10 changes: 6 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo " get_diff: ${INPUT_GET_DIFF}"
echo " old_string: ${INPUT_OLD_STRING}"
echo " new_string: ${INPUT_NEW_STRING}"
echo " ignore_users: ${INPUT_IGNORE_USERS}"
echo " check_diff: ${INPUT_CHECK_DIFF}"
echo " allow_no_diff: ${INPUT_ALLOW_NO_DIFF}"

# Skip whole script to not cause errors
IFS=',' read -r -a IGNORE_USERS <<< "${INPUT_IGNORE_USERS}"
Expand Down Expand Up @@ -66,9 +66,11 @@ if [[ $(git rev-parse --revs-only "${SOURCE_BRANCH}") == $(git rev-parse --revs-
exit 0
fi

if [[ "${INPUT_CHECK_DIFF}" == "true" ]]; then
echo -e "\nComparing branches by diff..."
if [[ -z $(git diff "remotes/origin/${TARGET_BRANCH}...remotes/origin/${SOURCE_BRANCH}") ]]; then
echo -e "\nComparing branches by diff..."
if [[ -z $(git diff "remotes/origin/${TARGET_BRANCH}...remotes/origin/${SOURCE_BRANCH}") ]]; then
if [[ "${INPUT_ALLOW_NO_DIFF}" == "true" ]]; then
echo -e "\n[INFO] Both branches are the same. Continuing."
else
echo -e "\n[INFO] Both branches are the same. No action needed."
exit 0
fi
Expand Down

0 comments on commit 5dd0639

Please sign in to comment.