-
Notifications
You must be signed in to change notification settings - Fork 1
30 lines (28 loc) · 1.14 KB
/
close_merge_request.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
name: Close MR on GitLab
on:
pull_request:
types: [closed]
jobs:
close-merge-request:
runs-on: ubuntu-latest
steps:
- name: close-merge-request
env:
GITLAB_API_ACCESS_TOKEN: ${{ secrets.GITLAB_API_ACCESS_TOKEN }}
GITLAB_API: ${{ secrets.GITLAB_API }}
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
PR_SOURCE_BRANCH: ${{ github.head_ref }}
PR_TARGET_BRANCH: ${{ github.base_ref }}
run: |
echo "PR_SOURCE_BRANCH: $PR_SOURCE_BRANCH"
echo "PR_TARGET_BRANCH: $PR_TARGET_BRANCH"
MR_IID=`curl \
--header "Content-Type: application/json" \
--header "PRIVATE-TOKEN: $GITLAB_API_ACCESS_TOKEN" \
"$GITLAB_API/projects/$GITLAB_PROJECT_ID/merge_requests?state=opened&source_branch=$PR_SOURCE_BRANCH&target_branch=$PR_TARGET_BRANCH" \
| jq '.[0].iid'`
curl \
--request PUT \
--header "Content-Type: application/json" \
--header "PRIVATE-TOKEN: $GITLAB_API_ACCESS_TOKEN" \
"$GITLAB_API/projects/$GITLAB_PROJECT_ID/merge_requests/$MR_IID?state_event=close"