-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 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,34 @@ | ||
# used to extract the version from a semver label | ||
name: get-semver-label-from-pr | ||
description: Gets semver label from PR event | ||
outputs: | ||
semver-label: | ||
description: Semver label name | ||
value: ${{ steps.get-label.outputs.result }} | ||
semver-bump: | ||
description: Semver bump type | ||
value: ${{ steps.get-bump.outputs.result }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/github-script@v6 | ||
id: get-label | ||
with: | ||
script: | | ||
const labels = context.payload.pull_request.labels | ||
const semverLabels = labels.filter(label => label.name.startsWith('semver:')) | ||
if (semverLabels.length === 0) { | ||
return core.setFailed('No semver label found') | ||
} | ||
if (semverLabels.length > 1) { | ||
return core.setFailed('Cannot have multiple semver labels') | ||
} | ||
return semverLabels[0].name | ||
- uses: actions/github-script@v6 | ||
id: get-bump | ||
if: ${{ success() }} | ||
env: | ||
LABEL_NAME: ${{ steps.get-label.outputs.result }} | ||
with: | ||
script: | | ||
return process.env.LABEL_NAME.replace('semver: ', '') |
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,31 @@ | ||
name: pr-has-semver-label | ||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
- labeled | ||
- unlabeled | ||
- ready_for_review | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
pr-has-semver-label: | ||
if: github.event.pull_request.draft == false | ||
name: pr-has-semver-label | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
sparse-checkout: | | ||
.github | ||
- name: Does the PR have a single semver label? | ||
id: get-semver-label | ||
uses: ./.github/actions/get-semver-label-from-pr | ||
- name: update GitHub Action summary | ||
id: set-semver-label-output | ||
if: ${{ success() }} | ||
run: echo "PR merge will cause a ${{ steps.get-semver-label.outputs.semver-bump }} version bump" >> $GITHUB_STEP_SUMMARY |