0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2024-11-21 17:36:59 -05:00

user: actions: document the default for shell

`jobs.<job_id>.steps[*].shell` defaults to `bash` unless
`jobs.<job_id>.container.image` is specified in which case it defaults
to `sh`.

Refs: https://code.forgejo.org/forgejo/runner/issues/150
This commit is contained in:
Earl Warren 2024-06-07 13:26:29 +02:00 committed by Earl Warren
parent e400655e1c
commit 6fa1c28677

View file

@ -704,7 +704,7 @@ steps:
### `jobs.<job_id>.container.image` ### `jobs.<job_id>.container.image`
- **Docker or Podman:** - **Docker or Podman:**
If the default image is unsuitable, a job can specify an alternate container image with `container:`, [as shown in this example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-container/.forgejo/workflows/test.yml). For instance the following will ensure the job is run using [Alpine 3.18](https://hub.docker.com/_/alpine/tags?name=3.18). If the default image is unsuitable, a job can specify an alternate container image with `container:`, [as shown in this example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-container/.forgejo/workflows/test.yml). If not specified, the shell defaults to `sh`. For instance the following will ensure the job is run using [Alpine 3.18](https://hub.docker.com/_/alpine/tags?name=3.18).
```yaml ```yaml
runs-on: docker runs-on: docker
@ -825,7 +825,7 @@ jobs:
steps: steps:
- run: | - run: |
grep Alpine /etc/os-release grep Alpine /etc/os-release
echo SUCCESS echo SUCCESS
``` ```
[Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-container/.forgejo/workflows/test.yml) [Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-container/.forgejo/workflows/test.yml)
@ -841,12 +841,41 @@ The working directory from which the script specified with `jobs.<job_id>.step[*
### `jobs.<job_id>.steps[*].shell` ### `jobs.<job_id>.steps[*].shell`
The shell used to run the script specified with `jobs.<job_id>.step[*].run`. For instance: The shell used to run the script specified with `jobs.<job_id>.step[*].run`. If not specified it defaults to `bash`.
For instance:
```yaml ```yaml
steps: jobs:
- shell: bash test:
run: echo $PATH runs-on: docker
steps:
- run: echo using bash here
```
Or to specify that `sh` must be used instead:
```yaml
jobs:
test:
runs-on: docker
steps:
- shell: sh
run: echo using sh here
```
If `jobs.<job_id>.container.image` is set and the shell is not specified, it defaults to `sh`.
For instance:
```yaml
jobs:
test:
runs-on: docker
container:
image: alpine:3.20
steps:
- run: echo using sh here
``` ```
[Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-pull-request/.forgejo/workflows/test.yml) [Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-pull-request/.forgejo/workflows/test.yml)