|
| 1 | +name: 'Spacedock Upload' |
| 2 | +description: 'Upload to spacedock, requires JQ already installed' |
| 3 | +inputs: |
| 4 | + username: |
| 5 | + description: "The spacedock username to upload with" |
| 6 | + required: true |
| 7 | + default: "" |
| 8 | + password: |
| 9 | + description: "The spacedock password to upload with" |
| 10 | + required: true |
| 11 | + default: "" |
| 12 | + game_id: |
| 13 | + description: "The ID of the game being uploaded to, used for grabbing game versions" |
| 14 | + required: true |
| 15 | + default: "" |
| 16 | + mod_id: |
| 17 | + description: "The ID of the mod you are updating" |
| 18 | + required: true |
| 19 | + default: "" |
| 20 | + version: |
| 21 | + description: "The version of your mod" |
| 22 | + required: true |
| 23 | + default: "" |
| 24 | + zipball: |
| 25 | + description: "The filename of your zipball" |
| 26 | + required: true |
| 27 | + default: "" |
| 28 | + changelog: |
| 29 | + description: "The filename of your changelog" |
| 30 | + required: true |
| 31 | + default: "" |
| 32 | + notify-followers: |
| 33 | + description: "Whether or not you want to notify followers" |
| 34 | + required: false |
| 35 | + default: "yes" |
| 36 | + spacedock_website: |
| 37 | + description: "The spacedock website being uploaded to (defaults to spacedock.info, can be alpha.spacedock.info, or beta.spacedock.info" |
| 38 | + required: false |
| 39 | + default: "spacedock.info" |
| 40 | +runs: |
| 41 | + using: "composite" |
| 42 | + steps: |
| 43 | + - name: Add mask (again to be sure) |
| 44 | + run: echo "::add-mask::${{ inputs.password }}" |
| 45 | + shell: bash |
| 46 | + - name: Log in to spacedock |
| 47 | + run: | |
| 48 | + login_response=$(curl -F username=${{ inputs.username }} -F password=${{ inputs.password }} -c ./cookies "https://${{ inputs.spacedock_website }}/api/login") |
| 49 | + login_errored=$(echo $login_response | jq .error) |
| 50 | + if [ "$login_errored" == "true" ]; then |
| 51 | + echo "Login to space dock errored: $(echo $login_response | jq .reason)" |
| 52 | + exit 1 |
| 53 | + else |
| 54 | + echo "Login to space dock successful" |
| 55 | + fi |
| 56 | + shell: bash |
| 57 | + - name: Query latest game version |
| 58 | + run: | |
| 59 | + echo "LATEST_GAME_VERSION=$(curl 'https://${{ inputs.spacedock_website }}/api/${{ inputs.game_id }}/versions' | jq '.[0].friendly_version' | tr -d \")" >> $GITHUB_ENV |
| 60 | + shell: bash |
| 61 | + |
| 62 | + - name: Update mod on spacedock |
| 63 | + run: | |
| 64 | + 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") |
| 65 | + errored=$(echo $result | jq .error) |
| 66 | + if [ "$errored" == "true" ]; then |
| 67 | + echo "Upload to space dock errored: $(echo $result | jq .reason)" |
| 68 | + exit 1 |
| 69 | + else |
| 70 | + echo "Upload to space dock successful" |
| 71 | + fi |
| 72 | + shell: bash |
0 commit comments