Skip to content

Commit e44528f

Browse files
docs: clarify Docker action pre-if metadata (#44466)
Co-authored-by: Stephen Gibler <261876204+sgibler-droid@users.noreply.github.com> Co-authored-by: Ben Ahmady <32935794+subatoi@users.noreply.github.com>
1 parent bbd0da3 commit e44528f

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎content/actions/reference/workflows-and-actions/metadata-syntax.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ runs:
399399

400400
### `runs.pre-entrypoint`
401401

402-
**Optional** Allows you to run a script before the `entrypoint` action begins. For example, you can use `pre-entrypoint:` to run a prerequisite setup script. {% data variables.product.prodname_actions %} uses `docker run` to launch this action, and runs the script inside a new container that uses the same base image. This means that the runtime state is different from the main `entrypoint` container, and any states you require must be accessed in either the workspace, `HOME`, or as a `STATE_` variable. The `pre-entrypoint:` action always runs by default but you can override this using [`runs.pre-if`](#runspre-if).
402+
**Optional** Allows you to run a script before the `entrypoint` action begins. For example, you can use `pre-entrypoint:` to run a prerequisite setup script. {% data variables.product.prodname_actions %} uses `docker run` to launch this action, and runs the script inside a new container that uses the same base image. This means that the runtime state is different from the main `entrypoint` container, and any states you require must be accessed in either the workspace, `HOME`, or as a `STATE_` variable. The `pre-entrypoint:` action always runs by default but you can override this using [`runs.pre-if`](#runspre-if-for-docker-container-actions).
403403

404404
The runtime specified with the [`using`](#runsusing-for-docker-container-actions) syntax will execute this file.
405405

@@ -415,6 +415,21 @@ runs:
415415
entrypoint: 'main.sh'
416416
```
417417

418+
### `runs.pre-if` for Docker container actions
419+
420+
**Optional** Allows you to define conditions for the `pre-entrypoint:` action execution. The `pre-entrypoint:` action will only run if the conditions in `pre-if` are met. If not set, then `pre-if` defaults to `always()`.
421+
422+
In this example, the `pre-entrypoint:` action runs only on Linux-based runners:
423+
424+
```yaml
425+
runs:
426+
using: 'docker'
427+
image: 'Dockerfile'
428+
pre-entrypoint: 'setup.sh'
429+
pre-if: runner.os == 'linux'
430+
entrypoint: 'main.sh'
431+
```
432+
418433
### `runs.image`
419434

420435
**Required** The Docker image to use as the container to run the action. The value can be the Docker base image name, a local `Dockerfile` in your repository, or a public image in Docker Hub or another registry. To reference a `Dockerfile` local to your repository, the file must be named `Dockerfile` and you must use a path relative to your action metadata file. The `docker` application will execute this file.

0 commit comments

Comments
 (0)