From 77380652376064e34aef9ebd42ff2223eb4c972a Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Fri, 20 Mar 2026 13:21:50 +0100 Subject: [PATCH] Enhance PocketBase workflow; fix installer scripts Workflow: add push trigger for main branch on json/*.json and update the "Get JSON file for script" step to handle both workflow_dispatch and push events. The step now collects changed json/*.json files, validates each has a .slug with jq, ignores metadata/update-apps.json/versions.json, writes changed_app_jsons.txt, and sets a count output for downstream steps. Installer & ct scripts: normalize indentation/formatting, ensure aliases.json and plugin-settings.json are initialized as {} and repos.json as [] when missing, and add missing trailing newlines. These changes improve robustness and shellcheck friendliness and make the workflow respond to direct pushes of app JSON files. --- .github/workflows/push_json_to_pocketbase.yml | 53 ++++++++++++++++--- ct/degoog.sh | 2 +- install/degoog-install.sh | 12 ++--- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/.github/workflows/push_json_to_pocketbase.yml b/.github/workflows/push_json_to_pocketbase.yml index 84c7349c2..11709dd5d 100644 --- a/.github/workflows/push_json_to_pocketbase.yml +++ b/.github/workflows/push_json_to_pocketbase.yml @@ -1,6 +1,11 @@ name: Push JSON changes to PocketBase on: + push: + branches: + - main + paths: + - "json/*.json" workflow_dispatch: inputs: script_slug: @@ -20,20 +25,52 @@ jobs: - name: Get JSON file for script id: changed run: | - script_slug="${{ github.event.inputs.script_slug }}" - file="json/${script_slug}.json" - if [[ ! -f "$file" ]]; then - echo "No JSON file at $file." + : > changed_app_jsons.txt + + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + script_slug="${{ github.event.inputs.script_slug }}" + file="json/${script_slug}.json" + if [[ ! -f "$file" ]]; then + echo "No JSON file at $file." + echo "count=0" >> "$GITHUB_OUTPUT" + exit 0 + fi + if ! jq -e '.slug' "$file" >/dev/null 2>&1; then + echo "File $file has no .slug." + echo "count=0" >> "$GITHUB_OUTPUT" + exit 0 + fi + echo "$file" > changed_app_jsons.txt + echo "count=1" >> "$GITHUB_OUTPUT" + exit 0 + fi + + changed=$(git diff --name-only "${{ github.event.before }}" "${{ github.event.after }}" -- json/*.json || true) + if [[ -z "$changed" ]]; then + echo "No JSON files changed under json/*.json." echo "count=0" >> "$GITHUB_OUTPUT" exit 0 fi - if ! jq -e '.slug' "$file" >/dev/null 2>&1; then - echo "File $file has no .slug." + + count=0 + for file in $changed; do + [[ -f "$file" ]] || continue + if [[ "$file" == "json/metadata.json" || "$file" == "json/update-apps.json" || "$file" == "json/versions.json" ]]; then + continue + fi + if jq -e '.slug' "$file" >/dev/null 2>&1; then + echo "$file" >> changed_app_jsons.txt + count=$((count + 1)) + fi + done + + if [[ $count -eq 0 ]]; then + echo "No app JSON files with .slug found in this push." echo "count=0" >> "$GITHUB_OUTPUT" exit 0 fi - echo "$file" > changed_app_jsons.txt - echo "count=1" >> "$GITHUB_OUTPUT" + + echo "count=$count" >> "$GITHUB_OUTPUT" - name: Push to PocketBase if: steps.changed.outputs.count != '0' diff --git a/ct/degoog.sh b/ct/degoog.sh index d3b5fc75b..55e624f99 100644 --- a/ct/degoog.sh +++ b/ct/degoog.sh @@ -70,4 +70,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4444${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4444${CL}" diff --git a/install/degoog-install.sh b/install/degoog-install.sh index d2ac5df7e..cb1dd23c8 100644 --- a/install/degoog-install.sh +++ b/install/degoog-install.sh @@ -15,8 +15,8 @@ update_os msg_info "Installing Dependencies" $STD apt install -y \ - git \ - unzip + git \ + unzip msg_ok "Installed Dependencies" msg_info "Installing Bun" @@ -44,19 +44,19 @@ DEGOOG_PLUGIN_SETTINGS_FILE=/opt/degoog/data/plugin-settings.json EOF if [[ ! -f /opt/degoog/data/aliases.json ]]; then - cat </opt/degoog/data/aliases.json + cat </opt/degoog/data/aliases.json {} EOF fi if [[ ! -f /opt/degoog/data/plugin-settings.json ]]; then - cat </opt/degoog/data/plugin-settings.json + cat </opt/degoog/data/plugin-settings.json {} EOF fi if [[ ! -f /opt/degoog/data/repos.json ]]; then - cat </opt/degoog/data/repos.json + cat </opt/degoog/data/repos.json [] EOF fi @@ -85,4 +85,4 @@ msg_ok "Created Service" motd_ssh customize -cleanup_lxc \ No newline at end of file +cleanup_lxc