Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdcdev committed Oct 14, 2023
1 parent 646fc06 commit df05313
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ inputs:
runs:
using: 'composite'
steps:

- name: Set env
shell: bash
run: |
Expand Down Expand Up @@ -99,13 +100,15 @@ runs:
echo "INPUT_LOGO_UPLOAD_PATH=${{ inputs.logoUploadPath }}" >> $GITHUB_ENV
echo "INPUT_IMAGES_UPLOAD_PATH=${{ inputs.imagesUploadPath }}" >> $GITHUB_ENV
echo "INPUT_IMAGE_ZIP=${{ inputs.imageZip }}" >> $GITHUB_ENV
- name: Install tools
shell: bash
run: |
sudo apt-get install pandoc
sudo apt-get install jq
sudo apt-get install zip
sudo apt-get install imagemagick
- name: Configure ImageMagick
shell: bash
run: |
Expand All @@ -114,17 +117,24 @@ runs:
sudo sed -i -E 's/name="map" value=".+"/name="map" value="8GiB"/g' /etc/ImageMagick-6/policy.xml
sudo sed -i -E 's/name="area" value=".+"/name="area" value="8GiB"/g' /etc/ImageMagick-6/policy.xml
sudo sed -i -E 's/name="disk" value=".+"/name="disk" value="8GiB"/g' /etc/ImageMagick-6/policy.xml
- name: Convert README.md to HTML
shell: bash
run: |
pandoc $INPUT_README_PATH -o README.html
README_HTML_SINGLE_LINE=$(cat README.html | tr '\n' ' ')
README_ENCODED=$(echo -n "$README_HTML_SINGLE_LINE" | jq -s -R -r @uri)
echo "README_HTML=$(printf '%q' "$README_ENCODED")" >> $GITHUB_ENV
- name: Generate Logo
shell: bash
if: ${{ ! -f "${{ env.INPUT_LOGO_PATH }}" }}
run: |
if [ -f "$INPUT_LOGO_PATH" ]; then
echo "Logo found at $INPUT_LOGO_PATH"
exit 1
fi
if [ "$INPUT_IMEJIS_GENERATE_IMAGE" == "false" ]; then
echo "No logo found at $INPUT_LOGO_PATH and IMEJIS_GENERATE_IMAGE is false. Downloading basic image."
text="$INPUT_PROJECT_NAME $INPUT_VERSION}"
Expand All @@ -133,19 +143,21 @@ runs:
exit 1
fi
echo "Downloading logo from imejis.io"
printf -v JSON_DATA '
{
"project": "%s",
"author": "%s",
"version": "%s"
}' "$INPUT_PROJECT_NAME" "$INPUT_PROJECT_AUTHOR" "$INPUT_VERSION"
echo "Downloading logo from imejis.io"
curl "https://api.imejis.io/api/designs/$INPUT_IMEJIS_DESIGN_ID" \
--header "dma-api-key: $INPUT_IMEJIS_KEY" \
--header 'Content-Type: application/json' \
--data "$JSON_DATA" \
--output "$INPUT_LOGO_PATH"
- name: Resize images for mod.io
shell: bash
run: |
Expand All @@ -166,10 +178,12 @@ runs:
fi
fi
done
- name: Zip images
shell: bash
run: |
zip -r -j "$INPUT_IMAGE_ZIP" "$INPUT_IMAGES_UPLOAD_PATH" "$INPUT_LOGO_UPLOAD_PATH"
- name: Remove images from mod.io
shell: bash
run: |
Expand All @@ -182,13 +196,15 @@ runs:
-H "Authorization: Bearer $INPUT_MODIO_TOKEN" \
-d "images[]=$filename"
done
- name: Upload images to mod.io
shell: bash
run: |
curl "https://api.mod.io/v1/games/$INPUT_MODIO_GAME/mods/$INPUT_MODIO_MOD/media" \
-H "Authorization: Bearer $INPUT_MODIO_TOKEN" \
-F "logo=@$INPUT_LOGO_UPLOAD_PATH" \
-F "images=@$INPUT_IMAGE_ZIP"
- name: Update modio mod description
shell: bash
run: |
Expand Down

0 comments on commit df05313

Please sign in to comment.