Skip to content

Commit

Permalink
♻️ refactor: Rewrite container address retrieval as a 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 0113218 commit c8311b5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/actions/ip-address/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: ip-address
description: >
Grabs a given container's IP address.
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"
8 changes: 4 additions & 4 deletions .github/workflows/ci:build:image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c8311b5

Please sign in to comment.