Skip to content

feat: enhance network configuration and diagnostics #4

feat: enhance network configuration and diagnostics

feat: enhance network configuration and diagnostics #4

Workflow file for this run

name: Container IP Example
on: [push]
jobs:
testing:
runs-on: ubuntu-latest
container:
image: golang:1.21-alpine
options: --sysctl net.ipv6.conf.all.disable_ipv6=0
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get Container IP from /etc/hosts
run: |
# Extract the container IP from /etc/hosts
CONTAINER_IP=$(grep $(hostname) /etc/hosts | awk '{ print $1 }')
echo "Container IP: $CONTAINER_IP"
CONTAINER_IPV6=$(grep $(hostname) /etc/hosts | grep -o '([a-fA-F0-9:]+:+)+[a-fA-F0-9]+')
cat /etc/hosts
echo "Container IPv6: $CONTAINER_IPV6"
# Set the container IP as an environment variable
echo "CONTAINER_IP=$CONTAINER_IP" >> $GITHUB_ENV
# Set the container IPv6 as an environment variable
echo "CONTAINER_IPV6=$CONTAINER_IPV6" >> $GITHUB_ENV
- name: Use Container IPv6
run: echo "The container IPv6 is ${{ env.CONTAINER_IPV6 }}"
- name: Use Container IP
run: echo "The container IP is ${{ env.CONTAINER_IP }}"