Skip to content

Commit

Permalink
Find available port
Browse files Browse the repository at this point in the history
Signed-off-by: Guian Gumpac <[email protected]>
  • Loading branch information
GumpacG committed Sep 18, 2024
1 parent 199793d commit 5902286
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/java-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,20 @@ jobs:
version: "26.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Find avalailable port for linux
os: ${{ matrix.host.OS == 'ubuntu'}}
- name: Find available port
id: port
run: |
apt install net-tools
while
port=$(shuf -n 1 -i 40000-65000)
netstat -atun | grep -q "$port"
do
continue
done
if ${{ matrix.host.OS == 'ubuntu'}}; then
apt install net-tools
while
port=$(shuf -n 1 -i 40000-65000)
netstat -atun | grep -q "$port"
do
continue
done
else
comm -23 <(seq 49152 65535 | sort) <(awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1 >> $port
fi
echo "PORT=$port" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 5902286

Please sign in to comment.