Skip to content

Commit

Permalink
feat: Allow check of diff between branch files to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
irphilli committed Jun 14, 2022
1 parent 3bac860 commit ecd94be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Features:
new_string: "** Automatic pull request**"
get_diff: true
ignore_users: "dependabot"
check_diff: true
```
Expand All @@ -62,6 +63,7 @@ Features:
| github_token | Yes | `""` | GitHub token `${{ secrets.GITHUB_TOKEN }}` |
| 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
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ inputs:
description: List of users to ignore, coma separated
required: false
default: "dependabot"
check_diff:
description: Whether to check if files differ before creating a PR
required: false
default: "true"
outputs:
url:
description: Pull request URL.
Expand Down
11 changes: 7 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +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}"

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

echo -e "\nComparing branches by diff..."
if [[ -z $(git diff "remotes/origin/${TARGET_BRANCH}...remotes/origin/${SOURCE_BRANCH}") ]]; then
echo -e "\n[INFO] Both branches are the same. No action needed."
exit 0
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 "\n[INFO] Both branches are the same. No action needed."
exit 0
fi
fi

# sed has problems with putting multi-line strings in the next steps, and later we use # for sed
Expand Down

0 comments on commit ecd94be

Please sign in to comment.