Repository navigation
Scripts: add a stack update script - #404
Draft
jackspiering wants to merge 4 commits into
Draft
jackspiering wants to merge 4 commits into
jackspiering wants to merge 4 commits into
Conversation
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/.
Download the service from GitHub instead of reading a full clone, and update compose.yaml and .env with a three-way merge against the upstream files that the last run saved in .scaletail/. This drops the base detection, the marker commit, --base, --ref and --no-fetch. - The first run replaces compose.yaml with a backup, and adds missing .env variables. - A conflict writes markers into the file, after a backup, and the next run refuses until they are resolved. - Target bash and GNU tools on Linux, not bash 3.2 and BSD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
scripts/update-stack.sh. It compares a stack folder that you copied out of the clone ("Run the stack from a copy") with the latest version of the service, and updatescompose.yamland.envwithout losing your changes. It targets bash and the GNU tools on Linux.main(about 350 KB) withcurlorwget, once per run. It needs no clone, and an existing clone is not read or changed.compose.yamland.envare compared and updated.ts/, the data folders, the README, and other files stay as they are.--applysaves the upstreamcompose.yamland.envin.scaletail/. The next run merges three versions withgit merge-file: your file, that saved copy, and the new upstream file. Each file that changes is first copied to.scaletail/backup-<time>/.docker composerefuses the file too, so nothing runs half-merged..envgets the variables it lacks, with their comments.compose.yamlis replaced by the upstream version: the diff is shown first, and your old file stays in the backup..envvalues, only variable names. It prints diffs ofcompose.yaml.SERVICEchanges upstream, unless--force. Prints the## Upgradingsection of the README when there are updates.--applyit runsdocker compose config --quietwhen Docker is available, and prints only whether it passed.Also adds
scripts/test-update-stack.sh(7 cases on a fake archive served from a temporary folder, no network), thescripts.ymlworkflow (ShellCheck and the test), and docs in the rootREADME.mdandAGENTS.md.Example output, from an old Gotify copy with an edited image tag and
.env(paths shortened):Related Issues
Verification
docker compose config --quietfrom each changed service directory, with dummy values for required variables. N/A: no service changed.rumdl check --config .markdownlint.yml .on the whole repository (rumdl 0.2.78, the pinned version), andgit diff --check origin/mainshellcheck scripts/*.sh(0.10.0): no findings.bash scripts/test-update-stack.sh: all checks pass. Two deliberate breakages (no.envappend, a.envvalue in the output) make it fail.compose.yamldiff shows the new iGotify service, and.envgets the 5 new variables.--applyreplacescompose.yamlwith a backup.docker compose configthen fails onrequired variable GOTIFY_DEFAULTUSER_PASS is missing, as the Upgrading section says, and the script reports the failure without quoting.env. A second run is up to date..envvalues: both files merge cleanly (output above), and the values do not appear in the output.restart:line next to the new iGotify block conflicts: the markers land incompose.yaml, the next run refuses, and after resolving it is up to date.gotifyin one run, the first with pending changes and the second up to date: the second reports up to date.--serviceworks for a folder with another name. A folder withcompose.ymlgets a hint to rename it.Impact on existing users
Checklist
Additional Context
--base,--ref,--no-fetch) with a download and a saved copy (about 260 lines). Squash-merge flattens both.git merge-fileis used instead ofdiff3 -mfrom diffutils, becausediff3 -mreports a conflict when both sides made the same change.Scripts:to the lists inAGENTS.mdandCONTRIBUTING.md.