-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (89 loc) · 3.23 KB
/
Copy pathpull-request.yml
File metadata and controls
105 lines (89 loc) · 3.23 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: "PR"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
- ready_for_review
jobs:
validate-title:
name: "Validate title"
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
permissions:
contents: read
pull-requests: write
steps:
- name: "Checkout repository"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm + Node.js
uses: ./.github/actions/setup-pnpm-node
- name: "Install dependencies"
run: pnpm install --frozen-lockfile
- name: "Validate PR title with commitlint"
id: commitlint
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
# Use commitlint to validate PR title (single source of truth)
echo "$PR_TITLE" | pnpm exec commitlint 2>&1 | tee /tmp/commitlint-output.txt
exit_code=${PIPESTATUS[1]}
# Capture output for the comment
{
echo 'error_message<<EOF'
cat /tmp/commitlint-output.txt
echo 'EOF'
} >> "$GITHUB_OUTPUT"
exit "$exit_code"
continue-on-error: true
- name: "Comment on PR with validation error"
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
if: steps.commitlint.outcome == 'failure'
with:
header: pr-title-lint-error
message: |
## ❌ PR Title Validation Failed
```
${{ steps.commitlint.outputs.error_message }}
```
> 📖 See [CONTRIBUTING.md](https://github.com/ls1intum/Hephaestus/blob/main/CONTRIBUTING.md) for commit message guidelines.
- name: "Remove error comment on success"
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
if: steps.commitlint.outcome == 'success'
with:
header: pr-title-lint-error
delete: true
- name: "Fail workflow if commitlint failed"
if: steps.commitlint.outcome == 'failure'
run: exit 1
assign-author:
name: "Assign author"
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.event.action == 'opened'
steps:
- uses: technote-space/assign-author@9558557c5c4816f38bd06176fbc324ba14bb3160 # v1
labeler:
name: "Apply labels"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: "Checkout repository"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5
with:
configuration-path: .github/labeler.yml
# v8 is the first release to run on Node 24, which is what executes the TypeScript below.
- name: "Apply size and semantic labels"
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const { default: labelPullRequest } = await import(
`${process.env.GITHUB_WORKSPACE}/.github/scripts/label-pr.ts`
)
await labelPullRequest({github, context})