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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #91 from irphilli/feature/allow-pr-no-diff #92

Merged
merged 4 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.4.2
VERSION := v0.5.0

# GitHub Actions bogus variables
GITHUB_REF ?= refs/heads/null
Expand Down
10 changes: 6 additions & 4 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 All @@ -37,7 +37,7 @@ Features:

```yaml
- name: Run the Action
uses: devops-infra/action-pull-request@v0.4.2
uses: devops-infra/action-pull-request@v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: development
Expand All @@ -54,12 +54,14 @@ Features:
new_string: "** Automatic pull request**"
get_diff: true
ignore_users: "dependabot"
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. |
| draft | No | `false` | Whether to mark it as a draft. |
Expand Down Expand Up @@ -116,7 +118,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create pull request
uses: devops-infra/action-pull-request@v0.4.2
uses: devops-infra/action-pull-request@v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title: Automatic pull request
Expand All @@ -138,7 +140,7 @@ jobs:
fetch-depth: 0
- name: Run the Action
if: startsWith(github.ref, 'refs/heads/feature')
uses: devops-infra/action-pull-request@v0.4.2
uses: devops-infra/action-pull-request@v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title: ${{ github.event.commits[0].message }}
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ inputs:
description: List of users to ignore, coma separated
required: false
default: "dependabot"
allow_no_diff:
description: Allows to continue on merge commits with no diffs
required: false
default: "false"
outputs:
url:
description: Pull request URL.
runs:
using: docker
image: docker://devopsinfra/action-pull-request:v0.4.2
image: docker://devopsinfra/action-pull-request:v0.5.0
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
branding:
Expand Down
9 changes: 7 additions & 2 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 " 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 @@ -67,8 +68,12 @@ 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_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
fi

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