-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(require-label): add new reusable workflow (#331)
Signed-off-by: M. Fatih Cırıt <[email protected]>
- Loading branch information
Showing
1 changed file
with
37 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,37 @@ | ||
name: require-label | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
label: | ||
required: true | ||
type: string | ||
outputs: | ||
result: | ||
value: ${{ jobs.require-label.outputs.result }} | ||
|
||
jobs: | ||
require-label: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
result: ${{ steps.require-label.outputs.result }} | ||
steps: | ||
- name: Check if label is present | ||
id: check-for-label | ||
if: contains(github.event.pull_request.labels.*.name, inputs.label) | ||
run: | | ||
echo "result=true" >> $GITHUB_OUTPUT | ||
echo "::notice::✅ The label is present: '${{ inputs.label }}'" | ||
shell: bash | ||
|
||
- name: Fail if label is not present | ||
if: steps.check-for-label.outputs.result != 'true' | ||
run: | | ||
echo "::error::❌ The label is missing: '${{ inputs.label }}'" | ||
echo "result=false" >> $GITHUB_OUTPUT | ||
echo "## 🚨 Missing Required Label" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "💡 Please add the following label to the pull request to proceed:" >> $GITHUB_STEP_SUMMARY | ||
echo "▶️ **${{ inputs.label }}**" >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
shell: bash |