diff --git a/.github/scripts/generate-pr-plugin.sh b/.github/scripts/generate-pr-plugin.sh index bc220ea9b..10570b4c9 100755 --- a/.github/scripts/generate-pr-plugin.sh +++ b/.github/scripts/generate-pr-plugin.sh @@ -21,7 +21,7 @@ fi # If no plugin URL provided, generate one based on R2 location if [ -z "$PLUGIN_URL" ]; then # Extract base URL from TXZ_URL and use consistent filename - PLUGIN_URL=$(echo "$TXZ_URL" | sed "s|\.tar\.gz|.plg|") + PLUGIN_URL="${TXZ_URL%.tar.gz}.plg" fi # Use consistent filename (no version in filename, version is inside the plugin) @@ -206,12 +206,16 @@ echo "⚠️ Remove this plugin before applying production updates" echo "====================================" echo "WebGUI PR Test Plugin Update" echo "====================================" -echo "Version: &version;" +echo "Version: VERSION_PLACEHOLDER" echo "" BACKUP_DIR="/boot/config/plugins/webgui-pr-PR_PLACEHOLDER/backups" MANIFEST="/boot/config/plugins/webgui-pr-PR_PLACEHOLDER/installed_files.txt" +# Remove old banner file to ensure new one gets created +echo "Removing old banner file..." +rm -rf "/usr/local/emhttp/plugins/webgui-pr-PR_PLACEHOLDER" + # First restore original files to ensure clean state if [ -f "$MANIFEST" ]; then echo "Step 1: Restoring original files before update..." @@ -246,6 +250,53 @@ fi echo "Step 2: Update will now proceed with installation of new PR files..." echo "" + +# The update continues by running the install method which will extract new files +]]> + + + + + + + + $(function() { + // Check for updates (non-dismissible) + caPluginUpdateCheck("webgui-pr-PR_PLACEHOLDER.plg", {noDismiss: true}); + + // Create banner with uninstall link (dismissible, but returns on update) + var bannerMessage = " " + + "Modified GUI installed via webgui-pr-PR_PLACEHOLDER plugin. " + + "Click here to uninstall"; + + // false = warning style, false = dismissible + addBannerWarning(bannerMessage, false, false); + + // Define uninstall function + window.uninstallPRPlugin = function() { + swal({ + title: "Uninstall PR Test Plugin?", + text: "This will restore all original files and remove the test plugin.", + type: "warning", + showCancelButton: true, + confirmButtonText: "Yes, uninstall", + cancelButtonText: "Cancel", + closeOnConfirm: false, + showLoaderOnConfirm: true + }, function(isConfirm) { + if (isConfirm) { + // Execute plugin removal using openPlugin (Unraid's standard method) + // The "refresh" parameter will automatically reload the page when uninstall is completed + openPlugin("plugin remove webgui-pr-PR_PLACEHOLDER.plg", "Removing PR Test Plugin", "", "refresh"); + } + }); + }; + }); + ]]> @@ -289,10 +340,11 @@ fi # Clean up echo "Cleaning up plugin files..." +# Remove the banner +rm -rf "/usr/local/emhttp/plugins/webgui-pr-PR_PLACEHOLDER" # Remove the plugin directory (which includes the tarball and backups) rm -rf "/boot/config/plugins/webgui-pr-PR_PLACEHOLDER" -# Remove the plugin file itself -rm -f "/boot/config/plugins/webgui-pr-PR_PLACEHOLDER.plg" +# Note: The .plg file is handled automatically by the plugin system and should not be removed here echo "" echo "✅ Plugin removed successfully" diff --git a/.github/workflows/pr-plugin-build.yml b/.github/workflows/pr-plugin-build.yml index 60f1daa7d..eee988ea4 100644 --- a/.github/workflows/pr-plugin-build.yml +++ b/.github/workflows/pr-plugin-build.yml @@ -179,10 +179,10 @@ jobs: - name: Comment on PR if: steps.changed-files.outputs.has_changes == 'true' - uses: peter-evans/create-or-update-comment@v4 + uses: marocchino/sticky-pull-request-comment@v2 with: - issue-number: ${{ github.event.pull_request.number }} - body: | + header: pr-plugin + message: | ## 🔧 PR Test Plugin Available A test plugin has been generated for this PR that includes the modified files. @@ -230,6 +230,4 @@ jobs: ``` --- - 🤖 This comment is automatically generated and will be updated with each new push to this PR. - edit-mode: replace - comment-id: deploy-comment \ No newline at end of file + 🤖 This comment is automatically generated and will be updated with each new push to this PR. \ No newline at end of file