-
Notifications
You must be signed in to change notification settings - Fork 269
190 lines (168 loc) · 7.54 KB
/
Copy pathlabel.yml
File metadata and controls
190 lines (168 loc) · 7.54 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Labeler
on:
pull_request:
# opened, reopened, and synchronize are default for pull_request
# edited - when PR title or body is changed
# labeled - when labels are added to PR
types: [opened, reopened, synchronize, edited, labeled]
push:
branches: [ main ]
paths:
- '../labels.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Disable all default permissions at workflow level for security (least privilege principle)
# Individual jobs will explicitly request only the permissions they need
permissions: {}
jobs:
label-syncer:
name: Syncer
runs-on: ubuntu-latest
permissions:
pull-requests: write # Needed to add existing labels to PRs
issues: write # Needed to create labels that do not already exist
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
labeler:
name: Set labels
needs: [label-syncer]
permissions:
contents: read # Required to read repository files and .github/labeler.yml configuration
pull-requests: write # Required to add/modify labels on pull requests
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
# Label based on modified files
- name: Label based on changed files
uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7.0.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
# Label based on branch name
- name: Label docs
if: startsWith(github.event.pull_request.head.ref, 'docs')
run: gh pr edit "$PR_NUMBER" --add-label "documentation" --repo ansys/pyaedt
- name: Label maintenance
if: |
startsWith(github.event.pull_request.head.ref, 'maint') ||
startsWith(github.event.pull_request.head.ref, 'ci')
run: gh pr edit "$PR_NUMBER" --add-label "maintenance" --repo ansys/pyaedt
- name: Label enhancement
if: startsWith(github.event.pull_request.head.ref, 'feat')
run: gh pr edit "$PR_NUMBER" --add-label "enhancement" --repo ansys/pyaedt
- name: Label bug
if: startsWith(github.event.pull_request.head.ref, 'fix')
run: gh pr edit "$PR_NUMBER" --add-label "bug" --repo ansys/pyaedt
- name: Label testing
if: startsWith(github.event.pull_request.head.ref, 'test')
run: gh pr edit "$PR_NUMBER" --add-label "testing" --repo ansys/pyaedt
- name: Label extension
if: |
contains(github.event.pull_request.title, 'extension') ||
contains(github.event.pull_request.title, 'extensions')
run: gh pr edit "$PR_NUMBER" --add-label "extensions" --repo ansys/pyaedt
- name: Label examples
if: contains(github.event.pull_request.title, 'pyaedt-examples')
run: gh pr edit "$PR_NUMBER" --add-label "examples" --repo ansys/pyaedt
# Label based on trailers in PR description and commit messages
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
sparse-checkout: .github/actions/label-from-trailers/action.yml
persist-credentials: false
sparse-checkout-cone-mode: false
- name: Label based on trailers
if: github.event_name == 'pull_request'
uses: ./.github/actions/label-from-trailers
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
commenter:
name: Suggest labels if none assigned
runs-on: ubuntu-latest
permissions:
contents: read # Required to read PR metadata
pull-requests: write # Required to post comments on pull requests
steps:
- name: Suggest to add labels
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
# Execute only when no labels have been applied to the pull request
if: toJSON(github.event.pull_request.labels.*.name) == '{}'
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Please add one of the following labels to add this contribution to the Release Notes :point_down:
- [bug](https://github.com/ansys/pyaedt/pulls?q=label%3Abug+)
- [documentation](https://github.com/ansys/pyaedt/pulls?q=label%3Adocumentation+)
- [enhancement](https://github.com/ansys/pyaedt/pulls?q=label%3Aenhancement+)
- [good first issue](https://github.com/ansys/pyaedt/pulls?q=label%3Agood+first+issue)
- [maintenance](https://github.com/ansys/pyaedt/pulls?q=label%3Amaintenance+)
- [release](https://github.com/ansys/pyaedt/pulls?q=label%3Arelease+)
- [testing](https://github.com/ansys/pyaedt/pulls?q=label%Atesting+)
changelog-fragment:
name: "Create changelog fragment"
needs: [labeler]
permissions:
contents: write # Required to commit changelog fragments to the repository
pull-requests: write # Required to update PR with changelog information
runs-on: ubuntu-latest
steps:
# NOTE: Temporary pin of ansys/actions to avoid the breaking change side effect.
- uses: ansys/actions/doc-changelog@84b6533ae76f5dde69a1df26c18682160a8121cf # v10.3.5
with:
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
use-pull-request-title: true
use-default-towncrier-config: true
use-python-cache: false
check-pr-template:
name: Check PR template
# NOTE: Disable checking for dependabot and other automated PRs
if: |
!startsWith(github.event.pull_request.title, 'BUILD(uv):') &&
!startsWith(github.event.pull_request.title, 'BUILD(actions):') &&
!startsWith(github.event.pull_request.title, 'BUILD(pre-commit):') &&
!startsWith(github.event.pull_request.title, 'CHORE: update CHANGELOG for v') &&
github.event.pull_request.user.login != 'pyansys-automation'
runs-on: ubuntu-latest
permissions:
pull-requests: read # Required to read PR content for validation
steps:
- name: Check PR description
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
ERRORS=()
# Check required sections exist
for section in "## Description" "## Issue linked" "## Checklist"; do
if ! echo "$PR_BODY" | grep -qF "$section"; then
ERRORS+=("Missing section: '$section'")
fi
done
# Check placeholder texts have been replaced
PLACEHOLDERS=(
"**Please provide a brief description of the changes made in this pull request.**"
"**Please mention the issue number or describe the problem this pull request addresses.**"
)
for placeholder in "${PLACEHOLDERS[@]}"; do
if echo "$PR_BODY" | grep -qF "$placeholder"; then
ERRORS+=("Placeholder not replaced: '$placeholder'")
fi
done
# Report
if [ ${#ERRORS[@]} -ne 0 ]; then
echo "PR description validation failed:"
for err in "${ERRORS[@]}"; do
echo " - $err"
done
exit 1
fi
echo "PR description is valid."