forked from CodeYourFuture/curriculum
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from reshamas/2-rs-ghactions-labels
Add GH action to require a semver label
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Require semver label before merge | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, labeled, unlabeled, synchronize] | ||
|
||
jobs: | ||
require-label: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check for required labels | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const requiredLabels = ['Semver-Major', 'Semver-Minor', 'Semver-Patch']; | ||
const labels = context.payload.pull_request.labels.map(label => label.name); | ||
const hasRequiredLabel = requiredLabels.some(label => labels.includes(label)); | ||
if (!hasRequiredLabel) { | ||
core.setFailed(`Pull request must have one of the following labels: ${requiredLabels.join(', ')}`); | ||
} |