diff --git a/.github/workflows/update-payload.yml b/.github/workflows/update-payload.yml
new file mode 100644
index 00000000..5d97f79b
--- /dev/null
+++ b/.github/workflows/update-payload.yml
@@ -0,0 +1,48 @@
+name: Update MokoCassiopeia Payload
+
+on:
+ push:
+ branches: [main]
+ workflow_dispatch:
+
+jobs:
+ update-payload:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Get latest MokoCassiopeia release URL
+ id: moko
+ run: |
+ DOWNLOAD_URL=$(curl -s https://api.github.com/repos/mokoconsulting-tech/MokoCassiopeia/releases \
+ | jq -r '[.[] | select(.assets | length > 0)][0].assets[0].browser_download_url')
+ echo "url=$DOWNLOAD_URL" >> $GITHUB_OUTPUT
+ echo "Found: $DOWNLOAD_URL"
+
+ - name: Download MokoCassiopeia zip
+ if: steps.moko.outputs.url != 'null'
+ run: |
+ mkdir -p src/payload
+ curl -sL "${{ steps.moko.outputs.url }}" -o src/payload/mokocassiopeia.zip
+ ls -la src/payload/
+
+ - name: Check if payload changed
+ id: diff
+ run: |
+ git add src/payload/mokocassiopeia.zip
+ if git diff --cached --quiet; then
+ echo "changed=false" >> $GITHUB_OUTPUT
+ else
+ echo "changed=true" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Commit updated payload
+ if: steps.diff.outputs.changed == 'true'
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git commit -m "chore: update mokocassiopeia payload"
+ git push
diff --git a/src/mokowaas.xml b/src/mokowaas.xml
index 774dfd41..b1883cc9 100644
--- a/src/mokowaas.xml
+++ b/src/mokowaas.xml
@@ -43,6 +43,7 @@
script.php
Extension
Field
+ payload
services
language
administrator
diff --git a/src/script.php b/src/script.php
index 74b0ca05..53b5fdc6 100644
--- a/src/script.php
+++ b/src/script.php
@@ -253,45 +253,29 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
return;
}
- // Template not installed — get download URL from updates.xml
- $updatesUrl = 'https://raw.githubusercontent.com'
- . '/mokoconsulting-tech/MokoCassiopeia/main/updates.xml';
+ // Template not installed — install from bundled payload
+ $pluginPath = JPATH_PLUGINS . '/system/mokowaas';
+ $payloadZip = $pluginPath . '/payload/mokocassiopeia.zip';
- $zipUrl = $this->getDownloadUrlFromUpdates($updatesUrl);
-
- if (empty($zipUrl))
+ if (!file_exists($payloadZip))
{
Factory::getApplication()->enqueueMessage(
- 'MokoCassiopeia: could not resolve download URL '
- . 'from updates.xml.',
+ 'MokoCassiopeia payload not found at '
+ . $payloadZip,
'warning'
);
return;
}
- $tmpFile = JPATH_ROOT . '/tmp/mokocassiopeia.zip';
- $tmpDir = JPATH_ROOT . '/tmp/mokocassiopeia';
+ $tmpDir = JPATH_ROOT . '/tmp/mokocassiopeia';
try
{
- $data = @file_get_contents($zipUrl);
- if ($data === false)
- {
- Factory::getApplication()->enqueueMessage(
- 'MokoCassiopeia download failed: ' . $zipUrl,
- 'warning'
- );
-
- return;
- }
-
- file_put_contents($tmpFile, $data);
-
- // Extract the release zip
+ // Extract the bundled zip
$archive = new \Joomla\Archive\Archive();
- $archive->extract($tmpFile, $tmpDir);
+ $archive->extract($payloadZip, $tmpDir);
// Release zips should have templateDetails.xml at root
// or one level deep
@@ -345,8 +329,6 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
}
finally
{
- @unlink($tmpFile);
-
if (is_dir($tmpDir))
{
Folder::delete($tmpDir);
@@ -449,32 +431,6 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
}
}
- private function getDownloadUrlFromUpdates($updatesUrl)
- {
- try
- {
- $xml = @file_get_contents($updatesUrl);
-
- if ($xml === false)
- {
- return null;
- }
-
- $updates = new \SimpleXMLElement($xml);
-
- if (isset($updates->update->downloads->downloadurl))
- {
- return (string) $updates->update->downloads->downloadurl;
- }
- }
- catch (\Exception $e)
- {
- return null;
- }
-
- return null;
- }
-
private const BLOCK_START = '; ===== BEGIN MokoWaaS Overrides (do not edit this block) =====';
/** Sentinel comment that marks the end of MokoWaaS overrides inside a Joomla override file. */