From ad83c53a1fbd9c99fc390a1ad66f4a003ac5572a Mon Sep 17 00:00:00 2001 From: Jack Spiering <46534141+jackspiering@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:50:35 +0100 Subject: [PATCH 1/6] Scripts: add a stack update script scripts/update-stack.sh checks stack folders that were copied out of a clone against the latest version in the repository and updates them with a three-way merge, so edits to .env and compose.yaml survive. It reads the upstream files with git only, never prints .env values, makes a backup before it writes, and never restarts containers. scripts/test-update-stack.sh tests it against a throwaway repository, and a new workflow runs ShellCheck and the test on changes to scripts/. --- .github/workflows/scripts.yml | 35 ++ AGENTS.md | 10 +- README.md | 21 +- scripts/test-update-stack.sh | 421 +++++++++++++++++++++ scripts/update-stack.sh | 679 ++++++++++++++++++++++++++++++++++ 5 files changed, 1164 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/scripts.yml create mode 100755 scripts/test-update-stack.sh create mode 100755 scripts/update-stack.sh diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml new file mode 100644 index 00000000..c8310a3b --- /dev/null +++ b/.github/workflows/scripts.yml @@ -0,0 +1,35 @@ +name: Test scripts +on: + workflow_dispatch: + push: + branches: + - main + paths: ['scripts/**', '.github/workflows/scripts.yml'] + pull_request: + branches: + - main + paths: ['scripts/**', '.github/workflows/scripts.yml'] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + scripts: + name: Scripts + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Clone this repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: ShellCheck + run: shellcheck scripts/*.sh + + - name: Run the update script tests + run: bash scripts/test-update-stack.sh diff --git a/AGENTS.md b/AGENTS.md index d6f08e23..b9bdb390 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,8 @@ ScaleTail is a collection of Docker Compose stacks. Each directory in `services/ - [CONTRIBUTING.md](CONTRIBUTING.md): how to add, update, verify, and submit a service. Follow it. - [templates/service-template/](templates/service-template/): the starting point for every service. Its comments explain each setting. - [documentation/standard-setup.md](documentation/standard-setup.md): the shared setup. A service README lists only what differs, under "Deviations from the standard setup". -- [.github/workflows/](.github/workflows/): the Compose validation and Markdown lint that CI runs. +- [scripts/](scripts/): `update-stack.sh` updates a stack that a user copied out of the clone, and `test-update-stack.sh` tests it. Keep both bash 3.2 and BSD compatible, because users run them on macOS. +- [.github/workflows/](.github/workflows/): the Compose validation, Markdown lint, and script tests that CI runs. ## Before you edit @@ -50,6 +51,13 @@ git diff --check origin/main Without `uv`, download that version from the [rumdl releases](https://github.com/rvben/rumdl/releases) and run `rumdl check --config .markdownlint.yml .`. +When you change `scripts/`, run the same checks as CI from the repository root: + +```sh +shellcheck scripts/*.sh +bash scripts/test-update-stack.sh +``` + Lint the whole tree, because renaming a service breaks a link in the root `README.md`. `git diff --check origin/main` also covers staged and committed changes, but not untracked files, so stage new files first. In a fork, compare with the `main` branch of this repository instead, for example `upstream/main`. When you have an auth key, start the copied stack and test its main function through the Tailnet. Run each health check command in its container with `docker exec`. diff --git a/README.md b/README.md index 8cb1be20..bf053a19 100644 --- a/README.md +++ b/README.md @@ -300,7 +300,26 @@ cp -R ScaleTail/services/ ~/stacks/ cd ~/stacks/ ``` -Your `.env`, the Tailscale state, and the application data now live outside the clone, so `git pull` in the clone never conflicts with them. A copy no longer follows the repository, so to pick up changes, update the clone and compare the files: +Your `.env`, the Tailscale state, and the application data now live outside the clone, so `git pull` in the clone never conflicts with them. A copy no longer follows the repository, so to pick up changes, run the update script from the clone. It compares your copy with the latest version in the repository and keeps your changes: + +```sh +ScaleTail/scripts/update-stack.sh ~/stacks/ +ScaleTail/scripts/update-stack.sh --apply ~/stacks/ +``` + +The first command only reports what would change and writes nothing. It exits with status 1 when updates are available. The second command writes the changes. Before it changes a file, it copies the file to a `.scaletail-backup-