-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (37 loc) · 1.5 KB
/
CHECK_PR_MERGED.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
on:
pull_request:
types: closed
jobs:
check_pr_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check PR Merged
id: check_pr_merged
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prUrl = context.payload.pull_request.html_url ?? context.payload.pull_request._links.html.href;
core.setOutput('pullRequestLink', JSON.stringify(prUrl));
- name: Send Slack Trigger
run: |
curl -X POST https://api-slack.internal.bcsdlab.com/api/pr-merged/frontend \
-H 'Content-Type: application/json' \
-d '{
"pullRequestLink": ${{ steps.check_pr_merged.outputs.pullRequestLink }}
}'
- name: Get branch names
id: get_branch_name
run: |
baseBranch=${{ github.event.pull_request.base.ref }}
headBranch=${{ github.event.pull_request.head.ref }}
echo "::set-output name=baseBranch::${baseBranch}"
echo "::set-output name=headBranch::${headBranch}"
- name: Delete Branch
if: ${{ steps.get_branch_name.outputs.headBranch != 'main' && steps.get_branch_name.outputs.headBranch != 'develop' }}
run: |
git checkout ${{ steps.get_branch_name.outputs.baseBranch }}
git push origin --delete ${{ steps.get_branch_name.outputs.headBranch }}