
GitHub Actions can be used to do something whenever something happens in one of your GitHub repositories. If you are not familiar with GitHub Actions, check out my article Getting Started with GitHub Actions.
I originally used haythem/public-ip to get the IPv4 address of the runner. But I started getting deprecation warning "Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: haythem/public-ip@v1.3" and it looks like the maintainer of haythem/public-ip has perhaps abandoned this repository as there were no recent commits and the following issue was stale - https://github.com/haythem/public-ip/issues/30.
So instead, I went with curl. Here is an example of how to get the IPv4 address of the runner using curl.
name: GitHub Action
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
push:
branches:
- main
jobs:
github-action-job:
runs-on: ubuntu-latest
steps:
- name: runner IPv4
id: ip
run: ipv4=$(curl --silent --url https://api.ipify.org); echo "ipv4=$ipv4" >> $GITHUB_OUTPUT
- name: echo ipv4
run: |
echo ${{ steps.ip.outputs.ipv4 }}
Did you find this article helpful?
If so, consider buying me a coffee over at