Skip to content

Commit f07b661

Browse files
authored
Update README.md
1 parent f180c20 commit f07b661

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

README.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,88 @@
1-
# check-branch-fast-forward-ness
1+
# What's it?
2+
3+
It's a simple composite Action in Bash, which checks if the Branch from Pull Request was merged into the main Branch where it was targeted into.
4+
5+
Action is performing the similar functional as the “Require branches to be up to date before merging” feature on GitHub. But this feature is not available for the private repositories without paid subscription.
6+
7+
![image](https://user-images.githubusercontent.com/11541555/134152498-13acb13e-a9c1-492b-a706-af3fff5aaa8c.png)
8+
9+
You can find the similar native function on GitHub in section Branches in repository's settings.
10+
11+
# What for?
12+
13+
Using this method can reassure you that the Pull Request Branch was tested in the context of your main Branch (or at least it is ready for launching and testing).
14+
15+
# How does it work?
16+
17+
Pretty simple and fast ≈ 6 ms.
18+
19+
Action is checking Pull Request Branch's fast-forward-ness, which means it can be easily merged, or ready to be merged with your main Branch. To do this, Action using this native git command:
20+
21+
```
22+
$ git merge-base --is-ancestor
23+
```
24+
25+
If the command is a success, everything is great and Action shows you 👍.
26+
27+
If the Pull Request Branch is not updated according to your main Branch, Action finishes with a error and shows you a pretty git log of your branches's tree, so you can investigate your problem it in place.
28+
29+
# How can I use it?
30+
It's really simple. **But it's only for Pull Requests workflows!**
31+
32+
Create file `check-fast-forward-ness.yml` in `.github/workflows` directory:
33+
34+
```yaml
35+
name: Check branch fast-forward-ness
36+
37+
on:
38+
pull_request:
39+
branches: [main]
40+
41+
jobs:
42+
check-fast-forward-ness:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: ViRGiL175/check-branch-fast-forward-ness@latest
47+
```
48+
49+
Now your Pull Requests will be tested on fast-forward-ness.
50+
51+
If your remote's name isn't "origin", you can use in parameter `remote-name` parameter to set the custom remote's name:
52+
53+
```yaml
54+
name: Check branch fast-forward-ness
55+
56+
on:
57+
pull_request:
58+
branches: [main]
59+
60+
jobs:
61+
check-fast-forward-ness:
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v2
65+
- uses: ViRGiL175/check-branch-fast-forward-ness@latest
66+
with:
67+
remote-name: different-remote-name
68+
```
69+
70+
# What's next?
71+
72+
Feel free to do any Forks and Pull Requests! For sure there are tonnes of bugs and there is much to improve.
73+
74+
> As far as I know, composite actions have some restrictions now, especially in the field of error handling. As the composite runner is developing, the code of this small Action can be made more useful and neat.
75+
76+
# Links
77+
78+
Inspiration:
79+
80+
[https://gist.github.com/briceburg/3f41f09bdc478d21bcf8](https://gist.github.com/briceburg/3f41f09bdc478d21bcf8)
81+
82+
My alias for the nice performing of the commit tree:
83+
84+
[https://gist.github.com/ViRGiL175/fad0e017c4bb638584c7233717b5122b](https://gist.github.com/ViRGiL175/fad0e017c4bb638584c7233717b5122b)
85+
86+
Social preview:
87+
88+
[Photo by lilartsy on Unsplash](https://unsplash.com/photos/eYbncUCBZm0)

0 commit comments

Comments
 (0)