Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technologiestiftung/warn-for-main-merge-action
A Github Action that adds a comment to a PR when a non-staging branch is the source and main the target
https://github.com/technologiestiftung/warn-for-main-merge-action
github-actions
Last synced: 30 days ago
JSON representation
A Github Action that adds a comment to a PR when a non-staging branch is the source and main the target
- Host: GitHub
- URL: https://github.com/technologiestiftung/warn-for-main-merge-action
- Owner: technologiestiftung
- License: mit
- Created: 2022-01-05T13:17:39.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-11T11:46:28.000Z (over 2 years ago)
- Last Synced: 2023-02-27T11:06:06.493Z (almost 2 years ago)
- Topics: github-actions
- Language: JavaScript
- Homepage:
- Size: 196 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![](https://img.shields.io/badge/Built%20with%20%E2%9D%A4%EF%B8%8F-at%20Technologiestiftung%20Berlin-blue)
# GitHub Action: Allow only staging/develop to merge into default/main/master branch
This Github Action fails when a PR from a non-staging branch into main is attempted.
This ensures that all branches excepted the staging branch are directly merged into the default/main branch.This action takes 2 inputs:
- **stagingName:** The name of the branch you use for development/staging
- **mainName:** The name of your default/main/master branchTo use in your repo, create a file in `/.github/workflows/warnForPRIntoMain.yml` like so:
```yml
name: "Prevent merge from non-staging to main"
on:
pull_request:
types: [opened, synchronize, reopened]jobs:
warn_main_merge:
runs-on: "ubuntu-latest"
name: "Validate PR Source and Target Branches"
steps:
- name: "Checking source and target branch in PR"
uses: "technologiestiftung/warn-for-main-merge-action@"
with:
stagingName: "develop" # CONFIGURE TO YOUR NEEDS -> Default is "staging"
mainName: "master" # CONFIGURE TO YOUR NEEDS -> Default is "main"
```In this case, the action will run as a check for your PRs, thus invalidating PRs that have `master` as a target and something else than `develop` as source. Any other source/target combination will succeed.
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## Credits