-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
78 lines (76 loc) · 2.78 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
name: 'Spacedock Upload'
description: 'Upload to spacedock, requires JQ already installed'
inputs:
username:
description: "The spacedock username to upload with"
required: true
default: ""
password:
description: "The spacedock password to upload with"
required: true
default: ""
game_id:
description: "The ID of the game being uploaded to, used for grabbing game versions"
required: true
default: ""
mod_id:
description: "The ID of the mod you are updating"
required: true
default: ""
version:
description: "The version of your mod"
required: true
default: ""
zipball:
description: "The filename of your zipball"
required: true
default: ""
changelog:
description: "The filename of your changelog"
required: true
default: ""
notify-followers:
description: "Whether or not you want to notify followers"
required: false
default: "yes"
spacedock_website:
description: "The spacedock website being uploaded to (defaults to spacedock.info, can be alpha.spacedock.info, or beta.spacedock.info"
required: false
default: "spacedock.info"
branding:
icon: 'upload'
color: 'blue'
runs:
using: "composite"
steps:
- name: Add mask (again to be sure)
run: echo "::add-mask::${{ inputs.password }}"
shell: bash
- name: Log in to spacedock
run: |
encoded_password=$(printf '%s' "${{ inputs.password }}" | jq -sRr @uri)
echo "::add-mask::$encoded_password"
login_response=$(curl -F "username=${{ inputs.username }}" -F "password=$encoded_password" -c ./cookies "https://${{ inputs.spacedock_website }}/api/login")
login_errored=$(echo $login_response | jq .error)
if [ "$login_errored" == "true" ]; then
echo "Login to space dock errored: $(echo $login_response | jq .reason)"
exit 1
else
echo "Login to space dock successful"
fi
shell: bash
- name: Query latest game version
run: |
echo "LATEST_GAME_VERSION=$(curl 'https://${{ inputs.spacedock_website }}/api/${{ inputs.game_id }}/versions' | jq '.[0].friendly_version' | tr -d \")" >> $GITHUB_ENV
shell: bash
- name: Update mod on spacedock
run: |
result=$(curl -b ./cookies -F "version=${{ inputs.version }}" -F "changelog=$(cat ${{ inputs.changelog }})" -F "game-version=${{ env.LATEST_GAME_VERSION }}" -F "notify-followers=yes" -F "zipball=@${{ inputs.zipball }}" "https://${{ inputs.spacedock_website }}/api/mod/${{ inputs.mod_id }}/update")
errored=$(echo $result | jq .error)
if [ "$errored" == "true" ]; then
echo "Upload to space dock errored: $(echo $result | jq .reason)"
exit 1
else
echo "Upload to space dock successful"
fi
shell: bash