refactor: Update Build Scripts And Workflows (#1848)

* refactor: Update Build Scripts And Workflows

* chore: Update Prettier Workflow

* chore: Update Publish Plugins Workflow

* chore: Update Prettier Workflow

* chore: Update Workflows

* chore: Update Workflows

* chore: Update Prettier Workflow

* chore: Update Prettier Workflow
This commit is contained in:
Rajarshee Chatterjee
2025-10-20 14:54:12 +05:30
committed by GitHub
parent 8108df39a1
commit 851330a52e
17 changed files with 648 additions and 500 deletions
+15 -11
View File
@@ -6,23 +6,28 @@ on:
- opened
- edited
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
auto-label:
name: Auto Label Issues
if: ${{ github.event.issue.body && contains(github.event.issue.body, '### Plugin') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v4
- name: Extract the severity from issue body
- name: Extract Severity From Issue Body
id: extract-severity
run: |
USER_SELECTED_SEVERITY=$(echo "${{ github.event.issue.body }}" | grep "### Severity" -A 2 | tail -n 1 | sed 's/[[:space:]]*$//')
SELECTED_SEVERITY=""
case "$USER_SELECTED_SEVERITY" in
"Wrong formatting"|"Wrong content"|"Missing chapter"|"Missing images"|"Can't load novels")
"Wrong Formatting"|"Wrong Content"|"Missing Chapter"|"Missing Images"|"Can't Load Novels"|"Domain Changed")
SELECTED_SEVERITY="$USER_SELECTED_SEVERITY"
;;
*)
@@ -31,14 +36,14 @@ jobs:
esac
echo "SELECTED_SEVERITY=$SELECTED_SEVERITY" >> $GITHUB_ENV
- name: Extract the plugin from issue body
- name: Extract Plugin From Issue Body
id: parse-issue
run: |
run: |
SELECTED_PLUGIN=$(echo "${{ github.event.issue.body }}" | awk '/### Plugin/ {f=1; next} f && NF {print; exit}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
echo "SELECTED_PLUGIN=$SELECTED_PLUGIN" >> $GITHUB_ENV
- name: Determine corresponding label
- name: Determine Corresponding Label
id: determine-label
run: |
LABELS="$( jq --arg keys "${{ env.SELECTED_PLUGIN }}" '. as $data | $keys | split(", ") as $keyList | $keyList[] | . as $key | if $data[$key] != null then "\($key)[\($data[$key])]" else empty end' ./.github/scripts/keys.json | sed 's/"//g' | sed 's/^[^:]*: //' )"
@@ -49,8 +54,7 @@ jobs:
# Save to GitHub environment
printf "LABELS<<EOF\n%s\nEOF\n" "$LABELS_WITH_PREFIX" >> $GITHUB_ENV
- name: Add label to the issue
- name: Add Labels To Issue
if: env.LABELS != ''
uses: actions-ecosystem/action-add-labels@v1
with:
@@ -59,6 +63,6 @@ jobs:
Severity: ${{ env.SELECTED_SEVERITY }}
${{ env.LABELS }}
- name: Handle missing label
- name: Handle Missing Label
if: env.LABELS == ''
run: echo "No matching label found for the selected plugin."
+11 -6
View File
@@ -1,4 +1,4 @@
name: Issue moderator
name: Issue Moderator
on:
issues:
@@ -6,11 +6,16 @@ on:
issue_comment:
types: [created]
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: false
jobs:
autoclose:
name: Auto Close Invalid Issues
runs-on: ubuntu-latest
steps:
- name: Moderate issues
- name: Moderate Issues
uses: tachiyomiorg/issue-moderator-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -18,10 +23,10 @@ jobs:
duplicate-check-enabled: true
duplicate-check-labels: |
["Source Request", "Domain Changed"]
["Plugin Request", "Domain Changed"]
existing-check-enabled: false
auto-close-rules: |
[
{
@@ -36,8 +41,8 @@ jobs:
},
{
"type": "title",
"regex": ".*(Source name|Short description).*",
"regex": ".*(Plugin name|Short description).*",
"message": "You did not fill out the description in the title"
}
]
auto-close-ignore-label: do-not-autoclose
auto-close-ignore-label: do-not-autoclose
+11 -8
View File
@@ -1,19 +1,22 @@
name: Lock threads
name: Lock Threads
on:
# Daily
schedule:
- cron: "0 0 * * *"
# Manual trigger
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
lock:
name: Lock Inactive Threads
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
- name: Lock Inactive Issues And Pull Requests
uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: "2"
pr-lock-inactive-days: "2"
issue-lock-inactive-days: '2'
pr-lock-inactive-days: '2'
+14 -10
View File
@@ -1,29 +1,33 @@
name: Prettier
name: Format Check
on:
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Prettier:
format-check:
name: Check Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
- name: Install Prettier
run: |
rm package.json
rm package-lock.json
npm init -y
npm pkg set type="module"
npm i prettier@3.2.5
npm install prettier@3.2.5
- name: Prettier
- name: Check Code Formatting
run: npx prettier --check "./src/**/*.{ts,tsx,js,css}"
@@ -2,35 +2,42 @@ name: Publish Plugins
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
Publish:
publish:
name: Publish Plugins
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SCOPED_TOKEN }}
- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm install --omit=dev --ignore-scripts
- name: Setup Git
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- if: github.repository == 'LNReader/lnreader-plugins'
name: Publish Plugins Main Repo
- name: Publish Plugins (Main Repository)
if: github.repository == 'LNReader/lnreader-plugins'
run: npm run publish:plugins 2>> $GITHUB_STEP_SUMMARY
shell: bash
- if: github.repository != 'LNReader/lnreader-plugins'
name: Publish Plugins All Branches
- name: Publish Plugins (Fork - All Branches)
if: github.repository != 'LNReader/lnreader-plugins'
run: npm run publish:plugins -- --all-branches
shell: bash
+45 -31
View File
@@ -4,20 +4,25 @@ on:
issues:
types: [labeled]
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
auto-label:
if: contains(github.event.issue.labels.*.name, 'Source Request')
name: Auto Label Theme
if: contains(github.event.issue.labels.*.name, 'Plugin Request')
runs-on: ubuntu-latest
env:
REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
steps:
- name: Get Source Request URL
- name: Get Plugin Website URL
id: get_url
env:
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
URL=$(echo "$ISSUE_BODY" | sed -n '/### Source link/,+2p' | sed '1,2d' | tr -d '[:space:]')
URL=$(echo "$ISSUE_BODY" | sed -n '/### Website URL/,+2p' | sed '1,2d' | tr -d '[:space:]')
echo "URL=$URL" >> $GITHUB_OUTPUT
echo "Using URL: \`$URL\`" >> $GITHUB_STEP_SUMMARY
@@ -36,71 +41,75 @@ jobs:
CHROME_VERSION=$(curl -s https://chromiumdash.appspot.com/fetch_releases?channel=Stable\&platform=Windows\&num=1 | jq -r '.[0].version // "126.0.6478.36"')
echo "USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$CHROME_VERSION Safari/537.36" >> $GITHUB_OUTPUT
- name: Check Madara theme
- name: Check Madara Theme
id: check_madara
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
if curl --location --output /dev/null --silent --head --fail "https://$BASE_URL/wp-content/themes/madara/style.css" -H "User-Agent: $USER_AGENT"; then
echo "madara=true" >> $GITHUB_OUTPUT
echo "✅ Madara Theme Detected" >> $GITHUB_STEP_SUMMARY
elif curl --location --output /dev/null --silent --head --fail "http://$BASE_URL/wp-content/themes/madara/style.css" -H "User-Agent: $USER_AGENT"; then
echo "🔍 Checking for Madara theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --output /dev/null --silent --head --fail --max-time 10 "https://$BASE_URL/wp-content/themes/madara/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null || \
curl --location --output /dev/null --silent --head --fail --max-time 10 "http://$BASE_URL/wp-content/themes/madara/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null; then
echo "madara=true" >> $GITHUB_OUTPUT
echo "✅ Madara Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "madara=false" >> $GITHUB_OUTPUT
echo "❌ Madara Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Check Lighnovelwp theme
- name: Check Lightnovelwp Theme
id: check_lighnovelwp
if: always() && steps.check_madara.outputs.madara != 'true'
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
if curl --location --output /dev/null --silent --head --fail "https://$BASE_URL/wp-content/themes/lightnovel/style.css" -H "User-Agent: $USER_AGENT"; then
echo "🔍 Checking for Lightnovelwp theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --output /dev/null --silent --head --fail --max-time 10 "https://$BASE_URL/wp-content/themes/lightnovel/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null || \
curl --location --output /dev/null --silent --head --fail --max-time 10 "http://$BASE_URL/wp-content/themes/lightnovel/style.css" -H "User-Agent: $USER_AGENT" 2>/dev/null; then
echo "lighnovelwp=true" >> $GITHUB_OUTPUT
echo "✅ Lighnovelwp Theme Detected" >> $GITHUB_STEP_SUMMARY
elif curl --location --output /dev/null --silent --head --fail "http://$BASE_URL/wp-content/themes/lightnovel/style.css" -H "User-Agent: $USER_AGENT"; then
echo "lighnovelwp=true" >> $GITHUB_OUTPUT
echo "✅ Lighnovelwp Theme Detected" >> $GITHUB_STEP_SUMMARY
echo "✅ Lightnovelwp Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "lighnovelwp=false" >> $GITHUB_OUTPUT
echo "❌ Lightnovelwp Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Check HotNovelPub theme
- name: Check HotNovelPub Theme
id: check_hotnovelpub
if: always() && steps.check_madara.outputs.madara != 'true' && steps.check_lighnovelwp.outputs.lighnovelwp != 'true'
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
if curl --location --silent --fail "https://api.$BASE_URL" -H "User-Agent: $USER_AGENT" | grep -q "Hello\!"; then
echo "hotnovelpub=true" >> $GITHUB_OUTPUT
echo "✅ HotNovelPub Theme Detected" >> $GITHUB_STEP_SUMMARY
elif curl --location --silent --fail "http://api.$BASE_URL" -H "User-Agent: $USER_AGENT" | grep -q "Hello\!"; then
echo "hotnovelpub=true" >> $GITHUB_OUTPUT
echo "✅ HotNovelPub Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "hotnovelpub=false" >> $GITHUB_OUTPUT
fi
echo "🔍 Checking for HotNovelPub theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --silent --fail --max-time 10 "https://api.$BASE_URL" -H "User-Agent: $USER_AGENT" 2>/dev/null | grep -q "Hello\!" || \
curl --location --silent --fail --max-time 10 "http://api.$BASE_URL" -H "User-Agent: $USER_AGENT" 2>/dev/null | grep -q "Hello\!"; then
echo "hotnovelpub=true" >> $GITHUB_OUTPUT
echo "✅ HotNovelPub Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "hotnovelpub=false" >> $GITHUB_OUTPUT
echo "❌ HotNovelPub Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Check Fictioneer theme
- name: Check Fictioneer Theme
id: check_fictioneer
if: always() && steps.check_madara.outputs.madara != 'true' && steps.check_lighnovelwp.outputs.lighnovelwp != 'true' && steps.check_hotnovelpub.outputs.hotnovelpub != 'true'
env:
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
run: |
if curl --location --output /dev/null --silent --head --fail "https://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT"; then
echo "fictioneer=true" >> $GITHUB_OUTPUT
echo "✅ Fictioneer Theme Detected" >> $GITHUB_STEP_SUMMARY
elif curl --location --output /dev/null --silent --head --fail "http://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT"; then
echo "🔍 Checking for Fictioneer theme..." >> $GITHUB_STEP_SUMMARY
if curl --location --output /dev/null --silent --head --fail --max-time 10 "https://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT" 2>/dev/null || \
curl --location --output /dev/null --silent --head --fail --max-time 10 "http://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT" 2>/dev/null; then
echo "fictioneer=true" >> $GITHUB_OUTPUT
echo "✅ Fictioneer Theme Detected" >> $GITHUB_STEP_SUMMARY
else
echo "fictioneer=false" >> $GITHUB_OUTPUT
echo "❌ Fictioneer Theme Not Found" >> $GITHUB_STEP_SUMMARY
fi
- name: Add Label
- name: Add Theme Label To Issue
if: always()
env:
MADARA: ${{ steps.check_madara.outputs.madara }}
LIGHNOVELWP: ${{ steps.check_lighnovelwp.outputs.lighnovelwp }}
@@ -108,14 +117,19 @@ jobs:
FICTIONEER: ${{ steps.check_fictioneer.outputs.fictioneer }}
GH_TOKEN: ${{ github.token }}
run: |
echo "## Theme Detection Result" >> $GITHUB_STEP_SUMMARY
if [[ "$MADARA" == "true" ]]; then
echo "🏷️ Adding label: Theme: Madara" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Madara" -R $REPO
elif [[ "$LIGHNOVELWP" == "true" ]]; then
echo "🏷️ Adding label: Theme: Lighnovelwp" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Lighnovelwp" -R $REPO
elif [[ "$HOTNOVELPUB" == "true" ]]; then
echo "🏷️ Adding label: Theme: Hotnovelpub" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Hotnovelpub" -R $REPO
elif [[ "$FICTIONEER" == "true" ]]; then
echo "🏷️ Adding label: Theme: Fictioneer" >> $GITHUB_STEP_SUMMARY
gh issue edit $ISSUE_NUMBER --add-label "Theme: Fictioneer" -R $REPO
else
echo "No Theme Detected" >> $GITHUB_STEP_SUMMARY
echo "❌ No Theme Detected" >> $GITHUB_STEP_SUMMARY
fi
@@ -0,0 +1,53 @@
name: Update Issue Template
on:
workflow_run:
workflows:
- Publish Plugins
types:
- completed
branches:
- master
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
update_template:
name: Update Issue Template
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
if: |
github.repository == 'LNReader/lnreader-plugins' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: master
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Generate Issue Template Options
run: node ./.github/scripts/generate-issue-template-options.cjs
- name: Create Or Update Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: 'chore: Update Issue Template Plugin Options [skip ci]'
branch: 'update-issue-template'
title: 'chore: Update Issue Template Plugin Options'
body: |
Updates the issue template with the latest plugin dropdown options.
This PR is automatically generated after plugins are published.
labels: 'bot'
base: 'master'
delete-branch: true
-38
View File
@@ -1,38 +0,0 @@
name: Update Issue Template
on:
workflow_run:
workflows:
- Publish Plugins
types:
- completed
jobs:
update_template:
if: github.repository == 'LNReader/lnreader-plugins' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Recreating report issue template
run: |
node ./.github/scripts/createOptions.cjs
- name: Create or Update Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: '[skip ci] Update issue template with plugin dropdown options'
branch: 'update-issue-template'
title: 'Update Issue Template'
body: |
This PR updates the issue template with the latest plugin dropdown options.
If this PR already exists, it will be updated automatically with the latest changes.
labels: 'bot'
base: 'master'
delete-branch: true