Container Bootstrap

Prepare a container environment for GitHub Actions before checkout.

This composite action handles three scenarios that arise when running GitHub Actions inside Docker containers:

  1. Node.js glibc patching — GitHub Actions ships its own Node.js binary (Node 20 at /e/node20/bin/node, Node 24 at /e/node24/bin/node), but older containers (e.g., Ubuntu 18.04) have a glibc too old for those binaries. This action detects the failure and replaces the Node 20 binary with the official unofficial-builds glibc-217 build. Node 24 patching is opt-in (see node24-url) and disabled by default, because no working glibc-217 Node 24 build exists yet — so containers that require Node 24 and a glibc older than 2.28 (GCC ⇐ 6 / Clang ⇐ 5) are unsupported.

  2. nektos/act support — When running locally with nektos/act, the /__e/ mechanism does not exist. This action installs system Node.js as a fallback.

  3. git safe.directory — Containers run as root while the workspace may be owned by a different user, causing git to refuse operations. This action sets safe.directory to *.

This action must be the first step in a job, before actions/checkout. It requires no Node.js runtime because it is a composite action that uses only bash steps.

No working glibc-217 Node 24 build exists yet (nodejs/unofficial-builds#190 has not shipped one, and the Boost mirror build crashes on heavy child_process operations on old kernels), so Node 24 patching is opt-in and off by default. Containers needing Node 24 on a pre-2.28 glibc (GCC ⇐ 6 / Clang ⇐ 5) are unsupported until a known-good build can be passed via node24-url.

The C++ Matrix action automatically configures the volume mounts (/node20217 and /node24) that this action writes to for old containers.

Usage

Basic usage (auto-detects everything):

steps:
  - name: Container Bootstrap
    uses: alandefreitas/cpp-actions/container-bootstrap@master

Custom Node.js version:

steps:
  - name: Container Bootstrap
    uses: alandefreitas/cpp-actions/container-bootstrap@master
    with:
      node-version: '20.11.0'

Custom mirror URL (e.g., Boost mirror at archives.boost.io):

steps:
  - name: Container Bootstrap
    uses: alandefreitas/cpp-actions/container-bootstrap@master
    with:
      node-url: 'https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.gz'

Input Parameters

Parameter

Description

Default

node-version

Node.js version to download from unofficial glibc-217 builds. Used only when the runner’s Node.js binary is broken inside the container. The URL is constructed as: https://unofficial-builds.nodejs.org/download/release/v<VERSION>/node-v<VERSION>-linux-x64-glibc-217.tar.gz NOTE: Node 24 glibc-217 builds do not exist. Only Node 20.x versions are available.

20.9.0

node-url

Override URL for the Node.js tarball. When non-empty, this URL is used instead of constructing one from node-version. Useful for custom mirrors. Example: https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.gz.

node24-url

URL of a glibc-217-compatible Node.js 24 tarball to patch into /node24 for old containers. Node 24 patching is OPT-IN and disabled by default, because no working glibc-217 Node 24 build exists yet: nodejs/unofficial-builds#190 has not shipped one, and the Boost archive mirror build crashes silently on heavy child_process operations (e.g. @actions/cache) on kernels older than 5.3. As a result, containers that require Node 24 and a glibc older than 2.28 (GCC ⇐ 6 / Clang ⇐ 5) are not supported. Set this to a known-good build to re-enable Node 24 patching once one exists. Example: https://example.com/node-v24.x.y-linux-x64-glibc-217.tar.xz.

setup-safe-directory

Whether to configure git config --global --add safe.directory '*'. Set to 'false' to skip safe.directory configuration.

true

trace-commands

Enable set -x in each step for debugging. Prints every command before execution. Consistent with the trace-commands input in other cpp-actions.

false

Outputs

Output

Description

node-patched

'true' if a glibc-217-compatible Node.js (20 and/or 24) was downloaded and installed, 'false' otherwise.

node24-patched

'true' if a glibc-217-compatible Node.js 24 was downloaded and installed into /node24, 'false' otherwise.

node-installed

'true' if system Node.js was installed via apt-get (act workaround), 'false' otherwise.

safe-directory-configured

'true' if git safe.directory was configured, 'false' otherwise.