Skip to content

Commit 31f014c

Browse files
Merge pull request #92 from devops-infra/develop
Merge pull request #91 from irphilli/feature/allow-pr-no-diff
2 parents 3bac860 + 396ddec commit 31f014c

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
phony: help
33

44
# Release tag for the action
5-
VERSION := v0.4.2
5+
VERSION := v0.5.0
66

77
# GitHub Actions bogus variables
88
GITHUB_REF ?= refs/heads/null

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Features:
1212
* Can assign `assignee`, `reviewer`, one or more `label`, a `milestone` or mark it as a `draft`
1313
* Can replace any `old_string` inside a pull request template with a `new_string`. Or put commits' subjects in place of `old_string`.
1414
* 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.
15-
15+
* 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.
1616

1717
## Badge swag
1818
[![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)
@@ -37,7 +37,7 @@ Features:
3737

3838
```yaml
3939
- name: Run the Action
40-
uses: devops-infra/action-pull-request@v0.4.2
40+
uses: devops-infra/action-pull-request@v0.5.0
4141
with:
4242
github_token: ${{ secrets.GITHUB_TOKEN }}
4343
source_branch: development
@@ -54,12 +54,14 @@ Features:
5454
new_string: "** Automatic pull request**"
5555
get_diff: true
5656
ignore_users: "dependabot"
57+
allow_no_diff: false
5758
```
5859
5960
6061
| Input Variable | Required | Default | Description |
6162
| -------------- | -------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
6263
| github_token | Yes | `""` | GitHub token `${{ secrets.GITHUB_TOKEN }}` |
64+
| allow_no_diff | No | `false` | Allows to continue on merge commits with no diffs. |
6365
| assignee | No | `""` | Assignee's usernames. |
6466
| body | No | *list of commits* | Pull request body. |
6567
| draft | No | `false` | Whether to mark it as a draft. |
@@ -116,7 +118,7 @@ jobs:
116118
- name: Checkout repository
117119
uses: actions/checkout@v2
118120
- name: Create pull request
119-
uses: devops-infra/action-pull-request@v0.4.2
121+
uses: devops-infra/action-pull-request@v0.5.0
120122
with:
121123
github_token: ${{ secrets.GITHUB_TOKEN }}
122124
title: Automatic pull request
@@ -138,7 +140,7 @@ jobs:
138140
fetch-depth: 0
139141
- name: Run the Action
140142
if: startsWith(github.ref, 'refs/heads/feature')
141-
uses: devops-infra/action-pull-request@v0.4.2
143+
uses: devops-infra/action-pull-request@v0.5.0
142144
with:
143145
github_token: ${{ secrets.GITHUB_TOKEN }}
144146
title: ${{ github.event.commits[0].message }}

action.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,16 @@ inputs:
6060
description: List of users to ignore, coma separated
6161
required: false
6262
default: "dependabot"
63+
allow_no_diff:
64+
description: Allows to continue on merge commits with no diffs
65+
required: false
66+
default: "false"
6367
outputs:
6468
url:
6569
description: Pull request URL.
6670
runs:
6771
using: docker
68-
image: docker://devopsinfra/action-pull-request:v0.4.2
72+
image: docker://devopsinfra/action-pull-request:v0.5.0
6973
env:
7074
GITHUB_TOKEN: ${{ inputs.github_token }}
7175
branding:

entrypoint.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ echo " get_diff: ${INPUT_GET_DIFF}"
2020
echo " old_string: ${INPUT_OLD_STRING}"
2121
echo " new_string: ${INPUT_NEW_STRING}"
2222
echo " ignore_users: ${INPUT_IGNORE_USERS}"
23+
echo " allow_no_diff: ${INPUT_ALLOW_NO_DIFF}"
2324

2425
# Skip whole script to not cause errors
2526
IFS=',' read -r -a IGNORE_USERS <<< "${INPUT_IGNORE_USERS}"
@@ -67,8 +68,12 @@ fi
6768

6869
echo -e "\nComparing branches by diff..."
6970
if [[ -z $(git diff "remotes/origin/${TARGET_BRANCH}...remotes/origin/${SOURCE_BRANCH}") ]]; then
70-
echo -e "\n[INFO] Both branches are the same. No action needed."
71-
exit 0
71+
if [[ "${INPUT_ALLOW_NO_DIFF}" == "true" ]]; then
72+
echo -e "\n[INFO] Both branches are the same. Continuing."
73+
else
74+
echo -e "\n[INFO] Both branches are the same. No action needed."
75+
exit 0
76+
fi
7277
fi
7378

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

0 commit comments

Comments
 (0)