-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (48 loc) · 1.73 KB
/
validate-issue-title.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
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Validate issue title
on:
issues:
types: [opened, edited]
workflow_dispatch:
jobs:
validate-and-label:
runs-on: ubuntu-latest
name: Validate issue title
permissions:
issues: write
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- name: Validate issue title
env:
NAME: ${{ github.event.issue.title }}
run: |
deno install
{
echo 'VALERR<<EOF'
echo "$(deno run './src/validate-issue-title.ts' "${NAME}" 2>&1 >/dev/null)"
echo EOF
} >> "$GITHUB_ENV"
- name: In case of an invalid issue title, comment about the error and label the issue
if: ${{ env.VALERR != '' && contains(github.event.issue.labels.*.name, 'checks/invalid-issue-title') != true }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
VALERR: ${{ env.VALERR }}
run: |
gh issue comment "${NUMBER}" --body "$(cat <<EOF
❌ The issue title is not properly formatted:
\`\`\`
${VALERR}
\`\`\`
EOF
)"
gh issue edit "${NUMBER}" --add-label 'checks/invalid-issue-title'
- name: In case of a valid issue title with an invalid label, remove the label from the issue
if: ${{ env.VALERR == '' && contains(github.event.issue.labels.*.name, 'checks/invalid-issue-title') == true }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
run: >
gh issue edit "${NUMBER}" --remove-label 'checks/invalid-issue-title'