Allowlist for task can take multiple hosts

This commit is contained in:
southerntofu 2020-09-16 12:07:03 +02:00
parent 101fa77894
commit 0887bd839f
2 changed files with 6 additions and 7 deletions

View File

@ -35,9 +35,9 @@ forgebuild looks up your ~/.forgebuild/ folder to find tasks to run. A task `t`
A task may also have the following optional files:
- t.branch: checkout the specified branch on the repository
- t.host: only run the task on a specific host, see [multihost setup](#multihost-setup)
- t.hosts: only run the task on a newline-separated list of hosts, see [multihost setup](#multihost-setup)
**TLDR**: a task `t` needs `t` (executable) and `t.source`, and accepts `t.branch` and `t.host`
**TLDR**: a task `t` needs `t` (executable) and `t.source`, and accepts `t.branch` and `t.hosts`
## Running tasks
@ -63,7 +63,7 @@ Any task receives the `$GITBUILDCONF` environment variable pointing to this repo
The distinctive feature of `forgebuild.sh` is the host-based configuration system. If a folder matching `$HOSTNAME` is found in your `~/.forgebuild/`, this folder will be passed to the task as `$GITBUILDCONF`, instead of the default configuration folder. If no host-specific configuration is found, the default configuration is used as explained previously.
Additionally, tasks can be configured to always/never run on a specific host. To run a task `t` on a single host, place a `t.host` file containing the target `$HOSTNAME` in `~/.forgebuild/`. To ignore a task on a specific host, place an empty `t.ignore` file in `~/.forgebuild/$HOSTNAME/`.
Additionally, tasks can be configured to always/never run on a specific host. To run a task `t` on a defined list of hosts, place a `t.hosts` file containing a hostname per line in `~/.forgebuild/`. To ignore a task on a specific host, place an empty `t.ignore` file in `~/.forgebuild/$HOSTNAME/`.
For an example of a multi-host setup, you can check out [my own ~/.forgebuild](https://tildegit.org/southerntofu/my-git-build).

View File

@ -176,10 +176,9 @@ for p_name in ${PROJECTS[*]}; do
export i18n_task="$p_name"
debug start_proc
# Check if task should run on host
if [ -f $BASEDIR/$p_name.host ]; then
for_host="$(cat $BASEDIR/$p_name.host)"
if [[ "$for_host" != "$HOSTNAME" ]]; then
# The task is specifically configured for a different host, ignore
if [ -f $BASEDIR/$p_name.hosts ]; then
if ! grep "^\s*$HOSTNAME\s*$" $BASEDIR/$p_name.hosts > /dev/null; then
# The task is specifically configured for different hosts, ignore
export i18n_host="$for_host"
debug skipped
continue