Skip to content

Commit

Permalink
ci(require-label): add new reusable workflow (#331)
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
xmfcx authored Dec 24, 2024
1 parent f33a673 commit 7d05dce
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/require-label.yaml
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

0 comments on commit 7d05dce

Please sign in to comment.