-
Notifications
You must be signed in to change notification settings - Fork 44
106 lines (100 loc) · 3.26 KB
/
05-merge-into-testing.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: merge into testing
on:
workflow_call:
inputs:
topic:
required: true
type: string
component:
required: true
type: string
message:
required: true
type: string
deploy:
required: true
type: string
workflow_dispatch:
inputs:
topic:
required: true
type: string
component:
required: true
type: string
message:
required: true
type: string
deploy:
required: true
type: string
env:
TOPIC: ${{ inputs.topic }}
COMPONENT: ${{ inputs.component }}
MSG: ${{ inputs.message }}
OSCPASS: ${{ secrets.OSCPASS }}
jobs:
merge:
name: merge repo
runs-on: ubuntu-latest
environment: TestingRepoReviewer
steps:
- name: Print Environment
run: export
- name: trigger repo merge
id: mergeid
run: |
set -x
sudo apt-get update && sudo apt install -y osc
mkdir -p ~/.config/osc
echo "${{ secrets.OSCRC }}" > ~/.config/osc/oscrc
osc co deepin:CI:TestingIntegration:${TOPIC} && cd $_
osc submitrequest --separate-requests deepin:Testing:"$COMPONENT" -m "${MSG}" --yes > sr.output|| true
mergeid=$(cat sr.output |grep "created:" |awk '{print $3}')
if [ -n "$mergeid" ];then
echo "mergeid=$mergeid" >> $GITHUB_OUTPUT
osc request accept -m "${MSG}" $mergeid ||true
else
skip=$(cat sr.output|grep "Skipping" ||true )
if [ -z "$skip" ];then
echo "obs merge request failed!"
exit 1
fi
fi
- name: Return merge status to pr
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const BOT_NAME = "TestingRepoMerge Bot"
const COMMENT_HEAD = "**" + BOT_NAME + "**\n\n"
mergeid = ${{ steps.mergeid.outputs.mergeid }}
//mergeid = 77
let COMMENT_BODY = ""
COMMENT_BODY += "Deepin Testing Repo Merge Info\nType: OBS\nStatus: https://build.deepin.com/request/show/"
COMMENT_BODY += mergeid
COMMENT_BODY += "\n"
if ( context.issue.number != undefined ) {
const response = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const reg = new RegExp("\\*+" + BOT_NAME + "\\*+")
tagBotComment= response.data.find(comment => comment.body.match(reg))
if (tagBotComment) {
await github.rest.issues.updateComment({
comment_id: tagBotComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: COMMENT_HEAD + COMMENT_BODY
})
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: COMMENT_HEAD + COMMENT_BODY
})
}
}