1- name : ' Sync mod.io README and Images'
2- description : ' Converts your README.md to HTML and uploads it to mod.io along with your images and logo. Optionally generates a logo from imejis.io'
3- author : ' James Carter'
1+ name : " Sync mod.io README and Images"
2+ description : " Converts your README.md to HTML and uploads it to mod.io along with your images and logo. Optionally generates a logo from imejis.io"
3+ author : " James Carter"
44branding :
5- icon : ' refresh-cw'
6- color : ' gray-dark'
5+ icon : " refresh-cw"
6+ color : " gray-dark"
77inputs :
8- logoPath :
9- description : ' Path to the logo.'
8+ logo-path :
9+ description : " Path to the logo."
1010 required : true
11- imagesPath :
12- description : ' Path to the images.'
11+ images-path :
12+ description : " Path to the images."
1313 required : true
14- readmePath :
15- description : ' Path to the README file.'
14+ readme-path :
15+ description : " Path to the README file."
1616 required : true
17- projectAuthor :
18- description : ' Author of the project.'
17+ project-author :
18+ description : " Author of the project."
1919 required : true
20- projectName :
21- description : ' Name of the project.'
20+ project-name :
21+ description : " Name of the project."
2222 required : true
2323 version :
24- description : ' Optional - Version of the mod. Defaults to latest github release.'
24+ description : " Optional - Version of the mod. Defaults to latest github release."
2525 required : false
26- projectUrl :
27- description : ' Homepage URL displayed on mod.io.'
26+ project-url :
27+ description : " Homepage URL displayed on mod.io."
2828 required : false
29- imejisGenerateImage :
30- description : ' Generate image from imejis.io.'
29+ imejis-generate-image :
30+ description : " Generate image from imejis.io."
3131 required : false
3232 default : " false"
33- imejisDesignId :
34- description : ' Imejis Design ID.'
33+ imejis-design-id :
34+ description : " Imejis Design ID."
3535 required : false
36- imejisKey :
37- description : ' Imejis Key.'
38- required : false
39- modioGame :
40- description : ' Mod.io Game Id.'
41- required : true
42- modioMod :
43- description : ' Mod.io Mod Id.'
36+ modio-game :
37+ description : " Mod.io Game Id."
4438 required : true
45- modioToken :
46- description : ' Mod.io Token. '
39+ modio-mod :
40+ description : " Mod.io Mod Id. "
4741 required : true
48- backgroundColor :
49- description : ' Optional - Background color used to pad resized images.'
42+ background-color :
43+ description : " Optional - Background color used to pad resized images."
5044 required : false
5145 default : " #0a1206"
52- imageSize :
53- description : ' Optional - ImageMagick resize image resolution.'
46+ image-size :
47+ description : " Optional - ImageMagick resize image resolution."
5448 required : false
5549 default : " 1920x1080"
56- logoUploadPath :
57- description : ' Optional - Path to upload the logo.'
50+ logo-upload-path :
51+ description : " Optional - Path to upload the logo."
5852 required : false
59- default : " temp_upload/0000_Logo .png"
60- imagesUploadPath :
61- description : ' Optional - Path to upload the images.'
53+ default : " temp_upload/0001_Logo .png"
54+ images-upload-path :
55+ description : " Optional - Path to upload the images."
6256 required : false
6357 default : " temp_upload"
64- imageZip :
65- description : ' Optional - Path to the zip file of the images.'
58+ image-zip :
59+ description : " Optional - Path to the zip file of the images."
6660 required : false
6761 default : " temp_upload/images.zip"
62+ imejis-key :
63+ description : " Imejis Key."
64+ required : false
65+ modio-token :
66+ description : " Mod.io Token."
67+ required : true
6868runs :
69- using : ' composite'
69+ using : " composite"
7070 steps :
71-
7271 - name : Set env
7372 shell : bash
7473 run : |
@@ -77,34 +76,34 @@ runs:
7776 else
7877 VERSION=${{ inputs.version }}
7978 fi
80- if "${{ inputs.projectUrl }}"" == ""; then
79+ if "${{ inputs.project-url }}"" == ""; then
8180 PROJECT_URL="${{ github.server_url }}/${{ github.repository }}"
8281 else
83- PROJECT_URL=${{ inputs.projectUrl }}
82+ PROJECT_URL=${{ inputs.project-url }}
8483 fi
8584 echo "INPUT_VERSION=$VERSION" >> $GITHUB_ENV
8685 echo "INPUT_PROJECT_URL=$PROJECT_URL" >> $GITHUB_ENV
87- echo "INPUT_LOGO_PATH=${{ inputs.logoPath }}" >> $GITHUB_ENV
88- echo "INPUT_IMAGES_PATH=${{ inputs.imagesPath }}" >> $GITHUB_ENV
89- echo "INPUT_README_PATH=${{ inputs.readmePath }}" >> $GITHUB_ENV
90- echo "INPUT_PROJECT_AUTHOR=${{ inputs.projectAuthor }}" >> $GITHUB_ENV
91- echo "INPUT_PROJECT_NAME=${{ inputs.projectName }}" >> $GITHUB_ENV
92- echo "INPUT_IMEJIS_GENERATE_IMAGE=${{ inputs.imejisGenerateImage }}" >> $GITHUB_ENV
93- echo "INPUT_IMEJIS_DESIGN_ID=${{ inputs.imejisDesignId }}" >> $GITHUB_ENV
94- echo "INPUT_IMEJIS_KEY=${{ inputs.imejisKey }}" >> $GITHUB_ENV
95- echo "INPUT_MODIO_GAME=${{ inputs.modioGame }}" >> $GITHUB_ENV
96- echo "INPUT_MODIO_MOD=${{ inputs.modioMod }}" >> $GITHUB_ENV
97- echo "INPUT_MODIO_TOKEN=${{ inputs.modioToken }}" >> $GITHUB_ENV
98- echo "INPUT_BACKGROUND_COLOR=${{ inputs.backgroundColor }}" >> $GITHUB_ENV
99- echo "INPUT_IMAGE_SIZE=${{ inputs.imageSize }}" >> $GITHUB_ENV
100- echo "INPUT_LOGO_UPLOAD_PATH=${{ inputs.logoUploadPath }}" >> $GITHUB_ENV
101- echo "INPUT_IMAGES_UPLOAD_PATH=${{ inputs.imagesUploadPath }}" >> $GITHUB_ENV
102- echo "INPUT_IMAGE_ZIP=${{ inputs.imageZip }}" >> $GITHUB_ENV
103-
86+ echo "INPUT_LOGO_PATH=${{ inputs.logo-path }}" >> $GITHUB_ENV
87+ echo "INPUT_IMAGES_PATH=${{ inputs.images-path }}" >> $GITHUB_ENV
88+ echo "INPUT_README_PATH=${{ inputs.readme-path }}" >> $GITHUB_ENV
89+ echo "INPUT_PROJECT_AUTHOR=${{ inputs.project-author }}" >> $GITHUB_ENV
90+ echo "INPUT_PROJECT_NAME=${{ inputs.project-name }}" >> $GITHUB_ENV
91+ echo "INPUT_IMEJIS_GENERATE_IMAGE=${{ inputs.imejis-generate-image }}" >> $GITHUB_ENV
92+ echo "INPUT_IMEJIS_DESIGN_ID=${{ inputs.imejis-design-id }}" >> $GITHUB_ENV
93+ echo "INPUT_IMEJIS_KEY=${{ inputs.imejis-key }}" >> $GITHUB_ENV
94+ echo "INPUT_MODIO_GAME=${{ inputs.modio-game }}" >> $GITHUB_ENV
95+ echo "INPUT_MODIO_MOD=${{ inputs.modio-mod }}" >> $GITHUB_ENV
96+ echo "INPUT_MODIO_TOKEN=${{ inputs.modio-token }}" >> $GITHUB_ENV
97+ echo "INPUT_BACKGROUND_COLOR=${{ inputs.background-color }}" >> $GITHUB_ENV
98+ echo "INPUT_IMAGE_SIZE=${{ inputs.image-size }}" >> $GITHUB_ENV
99+ echo "INPUT_LOGO_UPLOAD_PATH=${{ inputs.logo-upload-path }}" >> $GITHUB_ENV
100+ echo "INPUT_IMAGES_UPLOAD_PATH=${{ inputs.images-upload-path }}" >> $GITHUB_ENV
101+ echo "INPUT_IMAGE_ZIP=${{ inputs.image-zip }}" >> $GITHUB_ENV
102+
104103 - name : Install tools
105104 shell : bash
106105 run : |
107- sudo apt-get -qq install pandoc jq zip imagemagick -y
106+ sudo apt-get -qq install pandoc jq zip imagemagick -y
108107
109108 - name : Configure ImageMagick
110109 shell : bash
@@ -114,18 +113,18 @@ runs:
114113 sudo sed -n -i -E 's/name="map" value=".+"/name="map" value="8GiB"/g' /etc/ImageMagick-6/policy.xml
115114 sudo sed -n -i -E 's/name="area" value=".+"/name="area" value="8GiB"/g' /etc/ImageMagick-6/policy.xml
116115 sudo sed -n -i -E 's/name="disk" value=".+"/name="disk" value="8GiB"/g' /etc/ImageMagick-6/policy.xml
117-
116+
118117 - name : Convert README.md to HTML
119118 shell : bash
120- run : |
119+ run : |
121120 pandoc $INPUT_README_PATH -o README.html --quiet
122121 readme_html_single_line=$(cat README.html | tr '\n' ' ')
123122 readme_encoded=$(echo -n "$readme_html_single_line" | jq -s -R -r @uri)
124123 echo "INPUT_README_HTML=$(printf '%q' "$readme_encoded")" >> $GITHUB_ENV
125-
124+
126125 - name : Generate Logo
127126 shell : bash
128- run : |
127+ run : |
129128 if [ -f "$INPUT_LOGO_PATH" ]; then
130129 echo "Logo found at $INPUT_LOGO_PATH. Using existing logo."
131130 elif [ "$INPUT_IMEJIS_GENERATE_IMAGE" == "false" ]; then
@@ -150,15 +149,15 @@ runs:
150149 --data "$JSON_DATA" \
151150 --output "$INPUT_LOGO_PATH"
152151 fi
153-
152+
154153 - name : Resize images for mod.io
155154 shell : bash
156155 run : |
157156 mkdir -p "$INPUT_IMAGES_UPLOAD_PATH"
158157 rm -rf "$INPUT_IMAGES_UPLOAD_PATH"/*
159158
160159 convert "$INPUT_LOGO_PATH" -resize "$INPUT_IMAGE_SIZE" -background "$INPUT_BACKGROUND_COLOR" -gravity center -extent "$INPUT_IMAGE_SIZE" "$INPUT_LOGO_UPLOAD_PATH"
161-
160+
162161 for file in $INPUT_IMAGES_PATH/*; do
163162 if [[ -f $file ]]; then
164163 filename=$(basename -- "$file")
@@ -171,37 +170,37 @@ runs:
171170 fi
172171 fi
173172 done
174-
173+
175174 - name : Zip images
176175 shell : bash
177176 run : |
178177 zip -r -j "$INPUT_IMAGE_ZIP" "$INPUT_IMAGES_UPLOAD_PATH" "$INPUT_LOGO_UPLOAD_PATH"
179-
178+
180179 - name : Remove images from mod.io
181180 shell : bash
182181 run : |
183182 response=$(curl -s -H "Authorization: Bearer $INPUT_MODIO_TOKEN" "https://api.mod.io/v1/games/$INPUT_MODIO_GAME/mods/$INPUT_MODIO_MOD")
184183 jsonResponse=$(echo "$response" | jq -r '.media.images[] | @base64')
185-
184+
186185 for image in $jsonResponse; do
187186 filename=$(echo "$image" | base64 --decode | jq -r '.filename')
188187 curl -X DELETE "https://api.mod.io/v1/games/$INPUT_MODIO_GAME/mods/$INPUT_MODIO_MOD/media" \
189188 -H "Authorization: Bearer $INPUT_MODIO_TOKEN" \
190189 -d "images[]=$filename"
191190 done
192-
191+
193192 - name : Upload images to mod.io
194193 shell : bash
195194 run : |
196195 curl "https://api.mod.io/v1/games/$INPUT_MODIO_GAME/mods/$INPUT_MODIO_MOD/media" \
197196 -H "Authorization: Bearer $INPUT_MODIO_TOKEN" \
198197 -F "logo=@$INPUT_LOGO_UPLOAD_PATH" \
199198 -F "images=@$INPUT_IMAGE_ZIP"
200-
199+
201200 - name : Update modio mod description
202201 shell : bash
203202 run : |
204203 curl -X PUT "https://api.mod.io/v1/games/$INPUT_MODIO_GAME/mods/$INPUT_MODIO_MOD" \
205204 -H "Authorization: Bearer $INPUT_MODIO_TOKEN" \
206205 -d "description=$INPUT_README_HTML" \
207- -d "homepage_url=$INPUT_PROJECT_URL"
206+ -d "homepage_url=$INPUT_PROJECT_URL"
0 commit comments