Skip to content

Commit

Permalink
♻️ refactor: Refactor .State loop as composite action.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 20, 2024
1 parent deea531 commit 0113218
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
35 changes: 35 additions & 0 deletions .github/actions/is-running/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: is-running
description: >
Checks if a given container is running.
inputs:

container:
required: true

timeout:
required: true
default: 30

polling-interval:
required: true
default: 1

runs:

using: composite

steps:

- name: Wait for container to be healthy

env:
NAME_OR_ID: ${{ inputs.container }}
TIMEOUT: ${{ inputs.timeout }}
POLLING_INTERVAL: ${{ inputs.polling-interval }}

shell: bash

run: |
timeout "${TIMEOUT}" bash -c \
'until docker inspect --format "{{json .State }}" "${NAME_OR_ID}" | jq -e ".Status == \"running\"" ; do sleep "${POLLING_INTERVAL}"; done'
10 changes: 6 additions & 4 deletions .github/workflows/ci:build:image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
scripts/assert-replica-set.js
.github/actions/is-healthy/action.yml
.github/actions/is-reachable/action.yml
.github/actions/is-running/action.yml
sparse-checkout-cone-mode: false

- name: Get server image URL
Expand Down Expand Up @@ -160,10 +161,11 @@ jobs:
"address=$(docker container inspect --format '{{ range.NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' server)" \
>> "$GITHUB_OUTPUT"
- name: Wait for server container to be running
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State }}" server | jq -e ".Status == \"running\"" ; do sleep 1; done'
- name: Wait for container to be running
uses: ./.github/actions/is-running
with:
container: server
timeout: 60

- name: Wait for server container port to be available
uses: ./.github/actions/is-reachable
Expand Down

0 comments on commit 0113218

Please sign in to comment.