refactor: optimize and clean up network configuration code #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
# Set the container IP as an environment variable | |
echo "CONTAINER_IP=$CONTAINER_IP" >> $GITHUB_ENV | |
- name: Use Container IP | |
run: echo "The container IP is ${{ env.CONTAINER_IP }}" |