I'm writing github workflow file that is using (docker container) services.
I tried to set the port of the service container with running actions-runner's name, like ${{ runner.name }}.
My workflows file looks like below. I'm using self-hosted-runners and ex is the label of my runner. Also actions-runner service is running on my linux server, version of actions-runner is actions-runner-linux-x64-2.298.2.tar.gz.
# example-job.yml
name: EXAMPLE JOB
'on':
push:
branches:
- develop
- master
pull_request:
types:
- opened
- synchronize
jobs:
...
test-chunks:
...
runs-on: [self-hosted, ex]
name: test-chunk-${{ matrix.ci_node_index }}
strategy:
fail-fast: false
matrix:
ci_node_total: [10]
ci_node_index: [0,1,2,3,4,5,6,7,8,9]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Echo runner context
run: echo "${{ toJSON(runner) }}"
...
services:
db:
image: 'mdillon/postgis:11-alpine'
env:
POSTGRES_DB: test
POSTGRES_USER: foo
POSTGRES_PASSWORD: foo
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
--health-retries 5
ports:
- '543${{ runner.name }}:5432'
...
When I run github action, the action immediately fails with error The workflow is not valid. .github/workflows/example-job.yml (Line: 124, Col: 13): Unrecognized named-value: 'runner'. Located at position 1 within expression: runner.name
.
I've been set port like '543${{ matrix.ci_node_index }}:5432' and it worked fine. I don't know why "runner" context doesn't work properly.
Or is there way to run linux shell script in initializing port number?