-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6add303
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM ubuntu:latest | ||
|
||
RUN apt update | ||
RUN apt install -y git | ||
|
||
COPY conflicts /conflicts | ||
|
||
ENTRYPOINT ["/conflicts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# integration-branch-merge-conflicts action | ||
|
||
This action checks if the current branch would produce merge conflicts when merged to a given integration branch. | ||
|
||
## Inputs | ||
|
||
### `branch` | ||
|
||
**Required** The name of the integration branch. Default `"main"`. | ||
|
||
## How to use it? | ||
This is a Github action, so it has to be added to a github workflow. | ||
A simple example of running this action on all pushes to the repository would be | ||
add a `main.yml` file under `.github/workflows` with the following content | ||
```yaml | ||
on: [push] | ||
|
||
jobs: | ||
merge_conflict_job: | ||
runs-on: ubuntu-latest | ||
name: Find merge conflicts | ||
steps: | ||
# Checkout the source code so we have some files to look at. | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 #Required : Since we need to read the history | ||
# Run the actual merge conflict detection | ||
- name: Merge Conflict detection | ||
uses: siscodeorg/[email protected] | ||
``` | ||
For this example, each push would trigger the merge conflict detection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: 'siscodeorg/integration-branch-merge-conflicts' | ||
description: 'This action checks if the current branch would produce merge conflicts when merged to a given integration branch.' | ||
inputs: | ||
branch: | ||
description: 'The name of the integration branch.' | ||
required: true | ||
default: 'main' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash -l | ||
if | ||
git merge-tree $(git merge-base origin/$1 HEAD) origin/$1 HEAD | grep -F -q "<<<<<<<" | ||
then | ||
echo "Found conflict marker" | ||
exit 1 | ||
fi | ||
|
||
echo "No conflicts found" | ||
exit 0 |