Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Creat waiting-to-merge action #1506

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

trillium
Copy link
Member

@trillium trillium commented Sep 7, 2023

Prevents merging when a waiting to merge label is applied

Fixes #1505

What changes did you make and why did you make them ?

  • Prevents merging of a PR if waiting to merge label is applied
  • Still needs to be tested once merged

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Want to review this pull request? Take a look at this documentation for a step by step guide!

From your project repository, check out a new branch and test the changes.

git checkout -b Spiteless-ts.1505 development
git pull https://github.com/Spiteless/VRMS.git ts.1505

Prevents merging when a `waiting to merge` label is applied
@evanyang1
Copy link
Member

Looked at it, but I need to read up more on yaml files.

@trillium
Copy link
Member Author

trillium commented Sep 7, 2023

@evanyang1 code is adapted from here. This additional action will only trigger when the conditional is met:

if: ${{ contains(github.event.*.labels.*.name, 'waiting to merge') }}

From there the workflow will fail with exit code 1, preventing the PR from being merged.

@MattPereira
Copy link
Contributor

MattPereira commented Sep 7, 2023

Looked at it, but I need to read up more on yaml files.

@evanyang1 The github action docs are your friend here

The on: specifies when the workflow should run. The jobs: allow you to specifiy a series of "jobs" to be executed as part of a workflow. The runs-on: specifies the container environment in the cloud where the workflow will run and the steps: specify the scripts to be executed

For this PR the environment is ubuntu and the steps run a basic bash script that logs some explanatory information and intentionally fails by exiting with a status code of 1 which is a standard error code for UNIX systems

The kicker is that just making the github aciton fail doesn't prevent a merge. You also have to add the workflow to the required checks through the settings tab of this repository which it looks like has already been done

Copy link
Contributor

@MattPereira MattPereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spiteless I took the liberty of adding the waiting to merge label for you and it looks good 👍

@trillium trillium merged commit 2037d5c into hackforla:development Sep 7, 2023
5 of 6 checks passed
@trillium trillium deleted the ts.1505 branch September 7, 2023 17:21
@MattPereira
Copy link
Contributor

@spiteless did you add the workflow to the status checks for the development branch?

I've never seen a failing check not prevent a merge before

image

@trillium
Copy link
Member Author

trillium commented Sep 7, 2023

@MattPereira No, I haven’t taken any further steps except this new action. I expected to have some trial and error that needs to be resolved since I don't know how I'd test these locally.

@MattPereira
Copy link
Contributor

MattPereira commented Sep 7, 2023

@spiteless You could test on your fork by adding the appropriate branch protection rule to the fork

For the official VRMS repository someone will need access to the "Settings" tab in order to add the rule that will actually block merge when the workflow from this PR fails

@trillium
Copy link
Member Author

trillium commented Sep 7, 2023

@MattPereira Pretty sure it's working now but please double check. I just tested here:

#1498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a github action that prevents a PR from being merged if label is applied
3 participants