Skip to content

Commit 501950c

Browse files
authored
Update label.yml
Signed-off-by: Bryan <[email protected]>
1 parent 49e4743 commit 501950c

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

‎.github/workflows/label.yml‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,55 @@
1+
name: Labeler
12

3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
schedule:
7+
- cron: '0 0 * * *' # Daily at midnight
8+
9+
env:
10+
LABELER_CONFIG: .github/labeler.yml
11+
12+
jobs:
13+
label:
14+
name: Apply Labels
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
pull-requests: write
19+
20+
steps:
21+
# Step to validate the existence of the labeler configuration file
22+
- name: Validate Labeler Configuration
23+
run: |
24+
if [ ! -f $LABELER_CONFIG ]; then
25+
echo "Configuration file $LABELER_CONFIG not found."
26+
exit 1
27+
fi
28+
29+
# Step to validate YAML syntax
30+
- name: Validate Labeler Configuration Syntax
31+
run: yamllint $LABELER_CONFIG
32+
33+
# Step to checkout the repository
34+
- name: Checkout Repository
35+
uses: actions/[email protected]
36+
37+
# Step to apply labels based on the configuration in .github/labeler.yml
38+
- name: Apply Labeler
39+
uses: actions/[email protected]
40+
with:
41+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
42+
43+
# Step to log the applied labels for better transparency
44+
- name: Log Applied Labels
45+
run: |
46+
echo "Labels have been applied."
47+
48+
# Optional: Step to notify on failure with detailed output
49+
- name: Notify on failure
50+
if: failure()
51+
run: |
52+
echo "Label application failed."
53+
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
54+
-d '{"body":"Label application failed. Logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" }' \
55+
${{ github.event.pull_request.comments_url }}

0 commit comments

Comments
 (0)