Skip to content

Commit

Permalink
Add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
alikindsys committed Sep 30, 2020
0 parents commit 6add303
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
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"]
31 changes: 31 additions & 0 deletions README.md
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.
12 changes: 12 additions & 0 deletions action.yml
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 }}
10 changes: 10 additions & 0 deletions conflicts
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

0 comments on commit 6add303

Please sign in to comment.