-
Notifications
You must be signed in to change notification settings - Fork 0
29 lines (23 loc) · 949 Bytes
/
ipv6.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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: Set up Docker
run: |
# Get the container ID of the current container
CONTAINER_ID=$(cat /proc/self/cgroup | grep 'docker' | sed 's/^.*\///' | tail -n 1)
echo "Container ID: $CONTAINER_ID"
# Get the container IP address using docker inspect
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_ID)
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 }}"