Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

3.3 KB
Raw Blame
#!/usr/bin/env bash

set -euo pipefail

mode="${1:-all}"
case "$mode" in
  fast) job="fast-gate" ;;
  docker) job="container" ;;
  all) job="" ;;
  cleanup) job="cleanup" ;;
  *)
    echo "Usage: $0 {fast|docker|all|cleanup}" >&2
    exit 2
    ;;
esac

command -v act >/dev/null 2>&1 || {
  echo "act is required: https://nektosact.com/installation/index.html" >&2
  exit 1
}

docker info >/dev/null 2>&1 || {
  echo "Docker is not running" >&2
  exit 1
}

if [[ -z "${DOCKER_HOST:-}" ]]; then
  DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null || true)
  export DOCKER_HOST
fi

head_sha=$(git rev-parse HEAD)
head_ref=$(git branch --show-current)
head_ref=${head_ref:-act-local}
event_file=$(mktemp "${TMPDIR:-/tmp}/homarr-act-event.XXXXXX")
environment_file=$(mktemp "${TMPDIR:-/tmp}/homarr-act-env.XXXXXX")
trap 'rm -f "$event_file" "$environment_file"' EXIT

json_escape() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g'; }

if [[ "$mode" == "cleanup" ]]; then
  event_name="workflow_dispatch"
  cat >"$event_file" <<EOF
{
  "inputs": { "operation": "cleanup", "pr_number": "1", "ref": "" },
  "repository": { "full_name": "homarr-labs/homarr" }
}
EOF
elif [[ "$mode" == "docker" || "$mode" == "all" ]]; then
  event_name="workflow_dispatch"
  cat >"$event_file" <<EOF
{
  "inputs": { "operation": "validate", "ref": "$head_sha" },
  "repository": { "full_name": "homarr-labs/homarr" }
}
EOF
else
  base_sha=$(git merge-base origin/dev HEAD)
  event_name="pull_request"
  safe_ref=$(json_escape "$head_ref")
  cat >"$event_file" <<EOF
{
  "action": "synchronize",
  "number": 1,
  "repository": { "full_name": "homarr-labs/homarr" },
  "pull_request": {
    "number": 1,
    "draft": false,
    "base": { "sha": "$base_sha", "ref": "dev" },
    "head": {
      "sha": "$head_sha",
      "ref": "$safe_ref",
      "repo": { "full_name": "homarr-labs/homarr" }
    }
  }
}
EOF
fi

runner_image="${ACT_RUNNER_IMAGE:-catthehacker/ubuntu:act-latest}"
args=(
  "$event_name"
  --workflows .github/workflows/ci.yml
  --eventpath "$event_file"
  --platform "ubuntu-latest=$runner_image"
  --container-architecture linux/amd64
  --env-file /dev/null
  --bind
  --env "DB_DRIVER=better-sqlite3"
  --env "TURBO_CACHE_DIR=$PWD/.turbo/cache"
  # Jobs share the dependency volume; installs must not race.
  --concurrent-jobs 1
)

# Ryuk mounts the host socket; rootless runners also need a reachable host address.
if [[ "$DOCKER_HOST" == unix://* ]]; then
  args+=(--env "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=${DOCKER_HOST#unix://}")
fi
if [[ -n "${ACT_TESTCONTAINERS_HOST:-}" ]]; then
  args+=(--env "TESTCONTAINERS_HOST_OVERRIDE=$ACT_TESTCONTAINERS_HOST")
fi

if [[ -n "$job" ]]; then
  args+=(--job "$job")
fi

git_common_dir=$(cd "$(git rev-parse --git-common-dir)" && pwd)
# Bun loads .env automatically; reproduce GitHub's checkout without local settings.
container_options="--volume $environment_file:$PWD/.env --volume homarr-act-bun-1-4-2-node-24-18-0-modules:$PWD/node_modules --volume homarr-act-bun-cache:/root/.bun/install/cache"
case "$git_common_dir" in
  "$PWD" | "$PWD"/*) ;;
  *) container_options="$container_options --volume $git_common_dir:$git_common_dir:ro" ;;
esac
args+=(--container-options "$container_options")

if [[ -n "${ACT_SECRET_FILE:-}" ]]; then
  args+=(--secret-file "$ACT_SECRET_FILE")
fi

act "${args[@]}"