-
Notifications
You must be signed in to change notification settings - Fork 3
153 lines (153 loc) · 7.9 KB
/
jami-store-decision-manager.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: jami-store-requests-manager-accept
run-name: Organization decision from ${{ github.actor }}
on:
issue_comment:
types: [edited, created]
jobs:
set-up:
if: contains(github.event.issue.labels.*.name, 'new upload request') && (startsWith(github.event.comment.body, '/accept') || startsWith(github.event.comment.body, '/decline')) && github.event.comment.author_association == 'MEMBER'
runs-on: ubuntu-latest
outputs:
repo: ${{ steps.repo.outputs.result }}
plugin: ${{ steps.find-plugin.outputs.result }}
pluginName: ${{ steps.find_plugin_name.outputs.result }}
pluginPlatform: ${{ steps.find-plugin-platform.outputs.result }}
steps:
- name: get-repo-base-name
id: repo
uses: actions/github-script@v6
with:
script: |
const repo = "${{ github.repository }}"
baseName = repo.split("/").at(-1);
return baseName;
- name: find uploaded plugin
id: find-plugin
uses: actions/github-script@v6
with:
script: |
const regex = /https?:\/\/.*\/.*\.jpl/;
const repo = "${{ github.repository }}"
const { data: comments } = await github.rest.issues.listComments({
owner: "${{ github.repository_owner}}",
repo: ${{ steps.repo.outputs.result }},
issue_number: ${{ github.event.issue.number }}
});
const uploadComment = comments.find(comment => comment.body.includes('/upload'));
return uploadComment === undefined ? null: uploadComment.body.match(regex);
- name: find the name of the plugin
id: find_plugin_name
run: |
PLUGIN_FILE=$(basename "${{ fromJSON(steps.find-plugin.outputs.result)[0] }}")
echo "result=${PLUGIN_FILE%.*}" >> $GITHUB_OUTPUT
- name: find the platform of the plugin
id: find-plugin-platform
run: |
curl -o ${{ github.workspace }}/plugin.jpl -L "${{ fromJSON(steps.find-plugin.outputs.result)[0] }}"
regex='^lib/([^/]+)/'
ARCHES=$(unzip -l ${{ github.workspace }}/plugin.jpl "lib/*" | grep lib | awk '{ print $NF }' | grep -oP "$regex" | awk -F'/' '{ print $2 }')
PLUGIN_ARCHES=$(jq -nR '[inputs]' <<< "${ARCHES[@]}")
if [[ $PLUGIN_ARCHES == *"windows"* || $PLUGIN_ARCHES == *"apple"* || $PLUGIN_ARCHES == *"linux"* ]]; then
TARGET_ARCH="desktop"
else
TARGET_ARCH="android"
fi
echo $TARGET_ARCH
echo "result="${TARGET_ARCH}"" >> $GITHUB_OUTPUT
handle-error:
needs: [set-up]
if: needs.set-up.outputs.plugin == 'null'
runs-on: ubuntu-latest
steps:
- name: handle error
id: handle-error
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
body: '${{ github.actor}}, Please wait the organization to upload the plugin.'
});
decline:
needs: [set-up]
name: Decline request
if: startsWith(github.event.comment.body, '/decline')
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: Decline request
id: decline-request
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
body: "The request was declined. Please check the reason and try again."
});
github.rest.issues.addLabels({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
labels: ['declined request']
});
accept-request:
needs: [set-up]
if: startsWith(github.event.comment.body, '/accept') && needs.set-up.outputs.plugin != 'null'
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Accept request
id: accept-request
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
body: 'The request was accepted. Please wait for the plugin to be uploaded.'
});
github.rest.issues.addLabels({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
labels: ['accepted request', 'waiting for upload']
});
const labels = await github.rest.issues.listLabelsOnIssue({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
});
console.log(labels);
const declinedRequestLabel = labels.data.find(label => label.name === 'declined request');
if (!declinedRequestLabel){
return;
}
github.rest.issues.removeLabel({
issue_number: ${{ github.event.issue.number }},
owner: "${{ github.repository_owner}}",
repo: ${{ needs.set-up.outputs.repo }},
name: 'declined request'
});
- name: Set up SSH connection
id: ssh-agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_CREDENTIALS }}
- name: Upload plugin
run: |
curl -o ${{ github.workspace }}/${{ needs.set-up.outputs.pluginName }}.jpl -L ${{ fromJSON(needs.set-up.outputs.plugin)[0] }}
VERSION=$(date '+%Y%m%d%H%M')
def BRANCH_VERSION=$(date '+%Y%m%d')
echo ${VERSION} > version
echo ${BRANCH_VERSION} > branchVersion
rsync --verbose ${{ github.workspace }}/version ${{ secrets.SSH_HOST_DL_RING_CX }}:${{ secrets.REMOTE_PATH }}/${{needs.set-up.outputs.pluginPlatform}}/version
rsync --verbose ${{ github.workspace }}/branchVersion ${{ secrets.SSH_HOST_DL_RING_CX }}:${{ secrets.REMOTE_PATH }}/${{needs.set-up.outputs.pluginPlatform}}/branchVersion
rsync --verbose ${{ github.workspace }}/${{ needs.set-up.outputs.pluginName }}.jpl ${{ secrets.SSH_HOST_DL_RING_CX }}:${{ secrets.REMOTE_PATH }}/${{needs.set-up.outputs.pluginPlatform}}/archive/${{ needs.set-up.outputs.pluginName }}-${VERSION}.jpl
rsync --verbose ${{ github.workspace }}/${{ needs.set-up.outputs.pluginName }}.jpl ${{ secrets.SSH_HOST_DL_RING_CX }}:${{ secrets.REMOTE_PATH }}/${{ needs.set-up.outputs.pluginName }}/${{needs.set-up.outputs.pluginPlatform}}/${{ needs.set-up.outputs.pluginName }}.jpl