Giter Club home page Giter Club logo

github-check-branch-fast-forward-ness's Introduction

What's it?

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.

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.

image

You can find the similar native function on GitHub in section Branches in repository's settings.

What for?

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).

How does it work?

Pretty simple and fast ≈ 6 ms.

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 uses this native git command:

$ git merge-base --is-ancestor

If the command is a success, everything is great and Action shows you 👍.

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.

How can I use it?

It's really simple. But it's only for Pull Requests workflows!

Create file check-fast-forward-ness.yml in .github/workflows directory:

name: Check branch fast-forward-ness

on:
  pull_request:
    branches: [main]
    types: [review_requested]

jobs:
  check-fast-forward-ness:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ViRGiL175/check-branch-fast-forward-ness@main

Now your Pull Requests will be tested on fast-forward-ness.

If your remote's name isn't "origin", you can use remote-name parameter to set the custom remote's name:

name: Check branch fast-forward-ness

on:
  pull_request:
    branches: [main]
    types: [review_requested]

jobs:
  check-fast-forward-ness:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ViRGiL175/check-branch-fast-forward-ness@main
        with:
          remote-name: different-remote-name

What's next?

Feel free to do any Forks and Pull Requests! For sure there are tonnes of bugs and there is much to improve.

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.

Links

Inspiration on branch fast-forward-ness:
https://gist.github.com/briceburg/3f41f09bdc478d21bcf8

My alias for the nice performing of the commit tree:
https://gist.github.com/ViRGiL175/fad0e017c4bb638584c7233717b5122b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.