-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
105 lines (90 loc) · 3.04 KB
/
action.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
name: MirrorChyan Release Note
description: MirrorChyan Release Note
author: MirrorChyan
branding:
icon: arrow-up
color: black
inputs:
version_name:
required: false
release_note:
required: false
auto_channel:
required: false
default: "true"
channel:
required: false
mirrorchyan_rid:
required: true
upload_token:
required: true
github_token:
required: false
# for test
fake_upload:
required: false
default: "false"
outputs:
error:
value: ${{ steps.upload.outputs.error }}
msg:
value: ${{ steps.upload.outputs.msg }}
response:
value: ${{ steps.upload.outputs.response }}
runs:
using: "composite"
steps:
- id: latest-release
if: ${{ inputs.version_name == '' }}
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
token: ${{ inputs.github_token }}
- name: Organize information
id: information
shell: bash
env:
version_name: ${{ inputs.version_name == '' && steps.latest-release.outputs.release || inputs.version_name }}
release_note: ${{ inputs.version_name == '' && steps.latest-release.outputs.description || inputs.release_note }}
run: |
if [[ ${{ inputs.auto_channel }} != false ]]; then
if [[ "$version_name" == *"alpha"* ]]; then
channel="alpha"
elif [[ "$version_name" == *"beta"* ]]; then
channel="beta"
elif [[ "$version_name" == *"rc"* ]]; then
channel="beta"
else
channel="stable"
fi
else
channel="${{ inputs.channel }}"
fi
jq -cn --arg version_name "$version_name" --arg channel "$channel" --arg content "$release_note" '$ARGS.named' > body.json
- name: Upload to MirrorChyan
id: upload
shell: bash
run: |
cat body.json
if [[ ${{ inputs.fake_upload }} != true ]]; then
response=$(curl --location --request PUT 'https://mirrorchyan.com/api/resources/${{ inputs.mirrorchyan_rid }}/versions/release-note' \
--header 'Authorization:${{ inputs.upload_token }}' \
--header "Content-Type: application/json" \
--data @body.json)
else
curl --output /dev/null --location --request PUT 'www.github.com' \
--header 'Authorization:${{ inputs.upload_token }}' \
--header "Content-Type: application/json" \
--data @body.json
response='{"code":0,"msg":"success","data":{"id":114514,"name":"${{ steps.information.outputs.version_name }}","number":1919810}}'
fi
echo "response=$response" | tee -a "$GITHUB_OUTPUT"
error=$(echo "$response" | jq .code)
msg=$(echo "$response" | jq .msg)
echo "error=$error" | tee -a "$GITHUB_OUTPUT"
echo "msg=$msg" | tee -a "$GITHUB_OUTPUT"
if [[ $error != 0 ]]; then
echo "Bad Response!"
exit 1
fi