forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (40 loc) · 1.61 KB
/
tag-pull-requests.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
name: Pull request
on:
pull_request_target:
permissions:
contents: read
jobs:
add-milestone:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get next milestone
id: next-milestone-string
uses: mikefarah/yq@master
with:
cmd: yq eval '.milestones.next-milestone' '.github/repo-metadata.yml'
- name: 'Convert milestone to Github #'
id: next-milestone-number
run: |
MILESTONE_NUMBER=$(curl --silent --request GET \
--url https://api.github.com/repos/Mudlet/Mudlet/milestones \
-H "Accept: application/vnd.github.v3+json" | \
jq '.[] | select(.title == "${{ steps.next-milestone-string.outputs.result }}").number')
echo "MILESTONE_NUMBER=$MILESTONE_NUMBER" >> "$GITHUB_ENV"
- name: Assign PR to milestone
env:
TOKEN: ${{ secrets.GH_PAT_UPDATE_PULL_REQUESTS }}
run: |
# Fetch pull request details
PR_DETAILS=$(curl -s --request GET \
-H "Accept: application/vnd.github.v3+json" \
--url ${{ github.event.pull_request.issue_url }} \
--header "authorization: token $TOKEN")
# Check if the pull request has a milestone already
if [ $(echo "$PR_DETAILS" | jq '.milestone == null') == "true" ]; then
curl -s --request PATCH \
-H "Accept: application/vnd.github.v3+json" \
--url ${{ github.event.pull_request.issue_url }} \
--header "authorization: token $TOKEN" \
--data '{"milestone": '"$MILESTONE_NUMBER"'}'
fi