Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cover (WIP) #564

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/06-add-cover.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/issuesAutomatedTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down