diff --git a/.github/ISSUE_TEMPLATE/06-add-cover.yml b/.github/ISSUE_TEMPLATE/06-add-cover.yml new file mode 100644 index 00000000..6f69717d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/06-add-cover.yml @@ -0,0 +1,35 @@ +name: 📕 Add cover game +description: Add to a existing game its cover +title: '[ADD_COVER] ' +labels: ["[ADD_COVER]"] +body: + - type: markdown + attributes: + value: | + Please fill in the following fields to add this game cover ! + - type: input + id: identifierValue + attributes: + label: Identifier + description: What is the game playlist ID or video ID on Youtube ? + placeholder: >- + ex. PLRfhDHeBTBJ56jE5Kb3Wb6vBZZKLgM0dR or dn6QTMujBiY + validations: + required: true + - type: input + id: imageURL + attributes: + label: Image URL + description: Put a public link accessible without authentification here + placeholder: https://image.jeuxvideo.com/images-sm/pc/a/x/axxlpc0f.jpg + validations: + required: true + - type: dropdown + id: folder + attributes: + label: Folder ? + description: What is the public folder + options: + - covers + - testscovers + default: 0 diff --git a/.github/workflows/issuesAutomatedTasks.yml b/.github/workflows/issuesAutomatedTasks.yml index 4b852539..5e7446d6 100644 --- a/.github/workflows/issuesAutomatedTasks.yml +++ b/.github/workflows/issuesAutomatedTasks.yml @@ -21,6 +21,7 @@ jobs: contains(github.event.issue.labels.*.name, '[DELETE_GAME]') && 'DELETE_GAME' || contains(github.event.issue.labels.*.name, '[ADD_BACKLOG]') && 'ADD_BACKLOG' || contains(github.event.issue.labels.*.name, '[DELETE_BACKLOG]') && 'DELETE_BACKLOG' || + contains(github.event.issue.labels.*.name, '[ADD_COVER]') && 'ADD_COVER' || 'UNKNOWN' }} run: echo "issue_type=${{ env.ISSUE_TYPE }}" >> $GITHUB_OUTPUT - id: set_template_file @@ -42,6 +43,9 @@ jobs: DELETE_BACKLOG) echo "template_file=05-delete-backlog.yml" >> $GITHUB_OUTPUT ;; + ADD_COVER) + echo "template_file=06-add-cover.yml" >> $GITHUB_OUTPUT + ;; esac process_issue: runs-on: ubuntu-latest @@ -89,6 +93,28 @@ jobs: node-version: "lts/*" - name: 💻 Install npm packages run: npm install better-sqlite3 --no-save + - name: 📕 Add cover + if: ${{ env.OPERATION == 'ADD_COVER' }} + run: | + # Extract URL and folder path from the JSON environment variable + REQUEST_URL=$(echo $REQUEST | jq -r '.imageURL') + REQUEST_FOLDER=$(echo $REQUEST | jq -r '.folder') + REQUEST_ID=$(echo $REQUEST | jq -r '.identifierValue') + + # Define the folder path variable + FOLDER_PATH="/public/$REQUEST_FOLDER/$REQUEST_ID" + + # Create the target folder if it doesn't exist + mkdir -p "$FOLDER_PATH" + + # Download the image without worrying about the extension + curl -L -o image_file "$REQUEST_URL" + + # Resize the image and convert to WebP format using npx sharp-cli + npx --yes sharp-cli -i ./image_file -o "$FOLDER_PATH/cover.webp" -f webp resize 250 250 --fit inside + + # Clean up the original file + rm image_file - name: 💿 Do actions in database run: | node automatedTasks.mjs "$OPERATION" "$REQUEST"