@@ -215,23 +215,43 @@ jobs:
215215 ports :
216216 # will assign a random free host port
217217 - 5432/tcp
218-
218+ redis :
219+ image : redis:6
220+ options : >-
221+ --health-cmd "redis-cli ping"
222+ --health-interval 10s
223+ --health-timeout 5s
224+ --health-retries 5
225+ --name redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
226+ ports :
227+ - 6379/tcp
228+
219229 steps :
220230 - name : Set self-hosted env variable to github env
221231 run : echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
222- - name : Set github token, hostname, port and docker network for self-hosted runner
232+ - name : Set up custom postgres and redis hostname, port and docker network for self-hosted runner
223233 if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
224- run : |
234+ env :
235+ REDIS_HOSTNAME : redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
236+ REDIS_PORT : 6379
237+ run : |
225238 {
226239 echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
227240 echo "POSTGRES_PORT=5432"
241+ echo "REDIS_HOSTNAME=redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
242+ echo "REDIS_PORT=6379"
228243 } >> "$GITHUB_ENV"
229- docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} "postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
230- - name : Set postgres connection details to hosted runner
244+ docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
245+ docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.REDIS_HOSTNAME }}
246+ - name : Set service connection details to hosted runner
231247 if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
232248 run : |
233- echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
234- echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
249+ {
250+ echo "POSTGRES_HOSTNAME=localhost"
251+ echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}"
252+ echo "REDIS_HOSTNAME=localhost"
253+ echo "REDIS_PORT=${{ job.services.redis.ports['6379'] }}"
254+ } >> "$GITHUB_ENV"
235255 - name : Checkout source repository
236256 uses : actions/checkout@v4
237257 with :
@@ -334,23 +354,45 @@ jobs:
334354 ports :
335355 # will assign a random free host port
336356 - 5432/tcp
357+
358+ redis :
359+ image : redis:6
360+ options : >-
361+ --health-cmd "redis-cli ping"
362+ --health-interval 10s
363+ --health-timeout 5s
364+ --health-retries 5
365+ --name redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
366+ ports :
367+ - 6379/tcp
337368
338369 steps :
339370 - name : Set system env variable to github env
340371 run : echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
341- - name : Set github token, hostname, port and docker network for self-hosted runner
372+ - name : Set up custom postgres and redis hostname, port and docker network for self-hosted runner
342373 if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
374+ env :
375+ REDIS_HOSTNAME : redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
376+ REDIS_PORT : 6379
343377 run : |
344378 {
345379 echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
346380 echo "POSTGRES_PORT=5432"
381+ echo "REDIS_HOSTNAME=redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
382+ echo "REDIS_PORT=6379"
347383 } >> "$GITHUB_ENV"
348384 docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
349- - name : Set postgres connection details to hosted runner
385+ docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.REDIS_HOSTNAME }}
386+
387+ - name : Set service connection details to hosted runner
350388 if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
351389 run : |
352- echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
353- echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
390+ {
391+ echo "POSTGRES_HOSTNAME=localhost"
392+ echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}"
393+ echo "REDIS_HOSTNAME=localhost"
394+ echo "REDIS_PORT=${{ job.services.redis.ports['6379'] }}"
395+ } >> "$GITHUB_ENV"
354396 - name : Checkout source repository
355397 uses : actions/checkout@v4
356398 with :
0 commit comments