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..eca02bda 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. They target bash and the GNU tools of Linux distributions. +- [.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`. @@ -58,5 +66,5 @@ Report the checks you ran. State any checks that credentials, hardware, permissi ## Pull requests -- Title the pull request `Service: what changes`, such as `Umami: new service`. For several services, list them or use `All services:`. For other areas, use `CI:`, `Docs:`, or `Template:`. +- Title the pull request `Service: what changes`, such as `Umami: new service`. For several services, list them or use `All services:`. For other areas, use `CI:`, `Docs:`, `Scripts:`, or `Template:`. - Fill in the [pull request template](.github/PULL_REQUEST_TEMPLATE.md). Maintainers apply the labels. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9258cdbf..55c0a574 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -210,6 +210,6 @@ Then confirm: Title the pull request `Service: what changes`, such as `Umami: new service`. For several services, list them or use `All services:`. For other areas, use -`CI:`, `Docs:`, or `Template:`. Fill in the pull request template, and report -the checks you ran and any checks you could not run. Maintainers apply the -labels. +`CI:`, `Docs:`, `Scripts:`, or `Template:`. Fill in the pull request template, +and report the checks you ran and any checks you could not run. Maintainers +apply the labels. diff --git a/README.md b/README.md index 793a0753..ba637bf2 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,32 @@ 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. To pick up changes, run the update script. It downloads the latest version of the service from GitHub, so the clone does not need to be up to date, and it runs on Linux with `bash`, `curl` or `wget`, `tar`, and `git`: + +```sh +ScaleTail/scripts/update-stack.sh ~/stacks/ +ScaleTail/scripts/update-stack.sh --apply ~/stacks/ +``` + +Without a clone, download the script once and run it with `bash`: + +```sh +curl -fsSLo ~/stacks/update-stack.sh https://raw.githubusercontent.com/tailscale-dev/ScaleTail/main/scripts/update-stack.sh +bash ~/stacks/update-stack.sh ~/stacks/ +``` + +The first command only reports what would change, and exits with status 1 when updates are available. The second command writes the changes to `compose.yaml` and `.env`. It copies each file that changes to `.scaletail/backup-