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.
This commit is contained in:
CanbiZ (MickLesk)
2026-03-20 13:21:50 +01:00
parent b833eb68eb
commit 7738065237
3 changed files with 52 additions and 15 deletions

View File

@@ -1,6 +1,11 @@
name: Push JSON changes to PocketBase name: Push JSON changes to PocketBase
on: on:
push:
branches:
- main
paths:
- "json/*.json"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
script_slug: script_slug:
@@ -20,20 +25,52 @@ jobs:
- name: Get JSON file for script - name: Get JSON file for script
id: changed id: changed
run: | run: |
script_slug="${{ github.event.inputs.script_slug }}" : > changed_app_jsons.txt
file="json/${script_slug}.json"
if [[ ! -f "$file" ]]; then if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "No JSON file at $file." 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" echo "count=0" >> "$GITHUB_OUTPUT"
exit 0 exit 0
fi 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" echo "count=0" >> "$GITHUB_OUTPUT"
exit 0 exit 0
fi fi
echo "$file" > changed_app_jsons.txt
echo "count=1" >> "$GITHUB_OUTPUT" echo "count=$count" >> "$GITHUB_OUTPUT"
- name: Push to PocketBase - name: Push to PocketBase
if: steps.changed.outputs.count != '0' if: steps.changed.outputs.count != '0'

View File

@@ -70,4 +70,4 @@ description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4444${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4444${CL}"

View File

@@ -15,8 +15,8 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt install -y \ $STD apt install -y \
git \ git \
unzip unzip
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Installing Bun" msg_info "Installing Bun"
@@ -44,19 +44,19 @@ DEGOOG_PLUGIN_SETTINGS_FILE=/opt/degoog/data/plugin-settings.json
EOF EOF
if [[ ! -f /opt/degoog/data/aliases.json ]]; then if [[ ! -f /opt/degoog/data/aliases.json ]]; then
cat <<EOF >/opt/degoog/data/aliases.json cat <<EOF >/opt/degoog/data/aliases.json
{} {}
EOF EOF
fi fi
if [[ ! -f /opt/degoog/data/plugin-settings.json ]]; then if [[ ! -f /opt/degoog/data/plugin-settings.json ]]; then
cat <<EOF >/opt/degoog/data/plugin-settings.json cat <<EOF >/opt/degoog/data/plugin-settings.json
{} {}
EOF EOF
fi fi
if [[ ! -f /opt/degoog/data/repos.json ]]; then if [[ ! -f /opt/degoog/data/repos.json ]]; then
cat <<EOF >/opt/degoog/data/repos.json cat <<EOF >/opt/degoog/data/repos.json
[] []
EOF EOF
fi fi
@@ -85,4 +85,4 @@ msg_ok "Created Service"
motd_ssh motd_ssh
customize customize
cleanup_lxc cleanup_lxc