-
Notifications
You must be signed in to change notification settings - Fork 26
37 lines (34 loc) · 1.22 KB
/
require-label.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: require-label
on:
workflow_call:
inputs:
label:
required: true
type: string
outputs:
result:
value: ${{ jobs.require-label.outputs.result }}
description: Returns 'true' if the label is present, empty otherwise (cannot return 'false')
jobs:
require-label:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.check-for-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 "## 🚨 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