-
Notifications
You must be signed in to change notification settings - Fork 175
79 lines (69 loc) · 2.34 KB
/
pull_request_opened.yml
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
name: Pull Request Opened
on:
pull_request:
types:
- opened
- labeled
- unlabeled
- edited
workflow_dispatch:
jobs:
set-labels:
runs-on: ubuntu-latest
steps:
- name: Labeler
uses: actions/labeler@v5.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
sync-labels: true
update-pr-title:
runs-on: ubuntu-latest
needs: set-labels
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get PR Info
id: get_pr
uses: octokit/request-action@v2.x
with:
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Labels
id: extract_labels
run: echo "::set-output name=labels::${{ toJSON(github.event.pull_request.labels.*.name) }}"
- name: Update PR Title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_TITLE=$(jq -r '.title' <<< "${{ steps.get_pr.outputs.data }}")
PR_LABELS="${{ steps.extract_labels.outputs.labels }}"
PREFIX=""
if [[ "$PR_LABELS" == *"Documentation"* ]]; then
PREFIX="[Docs]"
elif [[ "$PR_LABELS" == *"NuGet"* ]]; then
PREFIX="[NuGet]"
elif [[ "$PR_LABELS" == *"Scripts"* ]]; then
PREFIX="[Scripts]"
elif [[ "$PR_LABELS" == *"regarding-events"* ]]; then
PREFIX="[Events]"
elif [[ "$PR_LABELS" == *"regarding-api"* ]]; then
PREFIX="[API]"
elif [[ "$PR_LABELS" == *"regarding-transpiler"* ]]; then
PREFIX="[Transpiler]"
elif [[ "$PR_LABELS" == *"CustomModules"* ]]; then
PREFIX="[CustomModules]"
elif [[ "$PR_LABELS" == *"Installer"* ]]; then
PREFIX="[Installer]"
elif [[ "$PR_LABELS" == *"GitHub_Actions"* ]]; then
PREFIX="[GitHub]"
fi
NEW_TITLE="$PREFIX $PR_TITLE"
if [[ "$NEW_TITLE" != "$PR_TITLE" ]]; then
curl -X PATCH \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \
-d "{\"title\":\"$NEW_TITLE\"}"
fi