Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify allowed contexts in jobs.<job_id>.services.<service_id>.image #33747

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Specify allowed contexts in jobs.<job_id>.services.<service_id>.image
Documentation does not mention if and which context variable can be used in `jobs.<job_id>.services.<service_id>.image`. From my tests a subset of contexts can be used and those are: `github`, `matrix`, `strategy`, `needs`, `vars` and inputs. 

Unfortunately, using `env` context is not possible. Not sure why but specifying allowed contexs in docs would be helpful when writing workflows. 

I've also changed conditional service creation example because it contained invalid example that was using `options` context which does not exist.
  • Loading branch information
piotrekkr authored Jun 27, 2024
commit c8b35d64e12974f6a026ebac61920d091ee509b6
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,16 @@ services:

The Docker image to use as the service container to run the action. The value can be the Docker Hub image name or a registry name.

> [!NOTE]
> Usage of GitHub [contexts](https://docs.github.com/en/actions/learn-github-actions/contexts) is allowed when specyfing service image.
> Allowed contexts are: `gitub`, `strategy`, `matrix`, `needs`, `vars` and `inputs`.

If `jobs.<job_id>.services.<service_id>.image` is assigned an empty string, the service will not start. You can use this to set up conditional services, similar to the following example.

```yaml
services:
nginx:
image: {% raw %}${{ options.nginx == true && 'nginx' || '' }}{% endraw %}
image: {% raw %}${{ matrix.nginx_service == 'true' && 'nginx' || '' }}{% endraw %}
```

## `jobs.<job_id>.services.<service_id>.credentials`
Expand Down