Global and per-job environment is not passed to service containers
@nikola-jokic is already working on this.
Since Mar 9, 2022.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Describe the bug
Environment variables set either globally via the top-level env: map or on a per-job basis are inconsistently passed to Docker containers started by job.<job_id>.services.
To Reproduce
Create a workflow with one or more environment variables set globally and/or on a Linux job, and ensure that the job contains at least one services: container. I encountered this issue specifically with a configuration similar to this:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
db:
- postgres:13
- postgres:12
- postgres:11
env:
POSTGRES_DB: not_postgres
POSTGRES_USER: not_postgres
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
container: swift:5.5-focal
services:
psql:
image: ${{ matrix.db }}
steps:
- uses: actions/checkout@v2
- run: swift test
The environment variables were applied to the steps, but not to the psql service container.
Expected behavior
I expected the environment variables to apply to the service container, as was the behavior observed in the past.
Runner Version and Platform
GitHub-hosted ubuntu-latest runners.
What's not working?
See above. I know that this used to work as expected, and that the behavior changed fairly recently. There is also no mention whatsoever of the effect of any environment variable settings on service containers anywhere in the documentation that I could find. As can be seen in the workflow I ended up with once I figured this out, this really hurt in having to repeat the same values over and over.
Job Log Output
Note: The GITHUB_ACTIONS and CI environment variables were passed to this service container, but that was all.
/usr/bin/docker create --name 98caa98add5e4da181f4fa892376e1a0_postgres13_2a5272 --label e1cc51 --network github_network_0d5cbb724d944e00ada110cfed9a3cd7 --network-alias psql-a -e GITHUB_ACTIONS=true -e CI=true postgres:13
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.