Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow check of diff between branch files to be configurable #91

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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