diff --git a/.github/actions/ip-address/action.yml b/.github/actions/ip-address/action.yml new file mode 100644 index 000000000..84d1836ac --- /dev/null +++ b/.github/actions/ip-address/action.yml @@ -0,0 +1,35 @@ +name: ip-address +description: > + Grabs the IP address of a given container. + +inputs: + + container: + required: true + +outputs: + + address: + description: > + The input container's IP address. + value: ${{ steps.fetch.outputs.address }} + +runs: + + using: composite + + steps: + + - name: Retrieve container IP address + + id: fetch + + env: + NAME_OR_ID: ${{ inputs.container }} + + shell: bash + + run: | + CONTAINER_IP_ADDRESS="$(docker container inspect --format '{{ range.NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' "${NAME_OR_ID}")" + echo "address=${CONTAINER_IP_ADDRESS}" >> "$GITHUB_OUTPUT" + test -n "${CONTAINER_IP_ADDRESS}" diff --git a/.github/workflows/ci:build:image.yml b/.github/workflows/ci:build:image.yml index 76162129f..280f7aee6 100644 --- a/.github/workflows/ci:build:image.yml +++ b/.github/workflows/ci:build:image.yml @@ -85,6 +85,7 @@ jobs: with: sparse-checkout: | scripts/assert-replica-set.js + .github/actions/ip-address/action.yml .github/actions/is-healthy/action.yml .github/actions/is-reachable/action.yml .github/actions/is-running/action.yml @@ -156,10 +157,9 @@ jobs: - name: Retrieve server container IP address id: server-container-ip-address - run: | - echo \ - "address=$(docker container inspect --format '{{ range.NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' server)" \ - >> "$GITHUB_OUTPUT" + uses: ./.github/actions/ip-address + with: + container: server - name: Wait for container to be running uses: ./.github/actions/is-running