# shellcheck shell=bash # How CI names, labels, and later finds the disposable stacks it starts. # # Every Compose project a CI script starts is named # # ekklesia-ci----- # # and Compose labels every container, network, and volume it creates with that name. What a script # creates outside Compose (a browser container, a volume, an image) gets EKKLESIA_CI_LABEL with the # same name. scripts/ci-sweep.sh finds stacks by those labels: this job's own, by the prefix up to # the job key (in a final `if: always()` step), and any CI stack by age (before a job starts). # # The job key is EKKLESIA_CI_JOB_KEY, which the workflow sets per job, and per matrix leg where a job # has one, so that one leg's cleanup cannot match another leg's running stack. Outside CI the # identifiers are "local". # shellcheck disable=SC2034 # read by the scripts that source this EKKLESIA_CI_LABEL="org.riverofglorymn.ekklesia.ci.project" # On images, when they were built, in Unix seconds. An image's own creation time is not that: BuildKit # gives an image that only adds metadata its base's time, and a reproducible build a fixed one. A # stale sweep that trusted it could remove an image another job is using right now. EKKLESIA_CI_CREATED_LABEL="org.riverofglorymn.ekklesia.ci.created" EKKLESIA_CI_PREFIX="ekklesia-ci-" # ci_name_safe : lower case, and only what a Compose project name may contain. ci_name_safe() { local text="${1//[^a-zA-Z0-9_-]/-}" printf '%s' "${text,,}" } # ci_job_prefix: every project this job starts begins with exactly this. ci_job_prefix() { ci_name_safe "ekklesia-ci-${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-0}-${EKKLESIA_CI_JOB_KEY:-${GITHUB_JOB:-local}}-" } # ci_project_name : a project name unique to this invocation. Not only per run: several runs, # and several jobs of one run, share a runner's Docker daemon, and job containers often share a PID. ci_project_name() { ci_name_safe "ekklesia-ci-${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-0}-${EKKLESIA_CI_JOB_KEY:-${GITHUB_JOB:-local}}-${1:?ci_project_name needs a kind}-$$-${RANDOM}${RANDOM}" }