Files
github-action/action.yml
T
Chlod Aidan Alejandro b72522a44b Permit use of action in all other repositories (#4)
* action.yml: force use external syntax for `uses`

This forces the use of the syntax for `uses` calling a specified subfolder of a public repository at a given ref. This is an attempt at moving away from the use of `./` as a path, which forces GitHub Actions to locate the `util/post/action.yml` of the *working directory* and not of the action path. This exists since `uses` cannot take expressions; this would be an easy fix if `./` can be replaced with `${{ github.action_path }}/`. Alas, this is not possible, and this hacky workaround exists instead.

* action.yml: use `action_path` instead of `./`

This replaces the use of `./` with `${{ github.action_path }}`, to allow the install scripts to run outside the action's repository, see b1b5340 for related commit.

* action.yml: wrap pwsh argument in quotes
2022-12-23 14:59:22 +01:00

77 lines
2.5 KiB
YAML

name: "ZeroTier"
description: "Connect your Github Action workflow to ZeroTier"
branding:
icon: 'globe'
color: 'gray-dark'
on:
workflow_call:
inputs:
network_id:
description: "The ZeroTier network ID to connect to"
required: true
auth_token:
description: "Your ZeroTier Central API Access Token"
required: true
api_url:
description: "ZeroTier Central API URL"
required: false
default: "https://my.zerotier.com/api/v1"
runs:
using: 'composite'
steps:
- name: zerotier
uses: zerotier/github-action/util/post@main
with:
main: |
set -euo pipefail
IFS=$'\n\t'
echo "⏁ Installing ZeroTier"
case $(uname -s) in
MINGW64_NT?*)
pwsh "${{ github.action_path }}/util/install.ps1"
ztcli="/c/Program Files (x86)/ZeroTier/One/zerotier-cli.bat"
member_id=$("${ztcli}" info | awk '{ print $3 }')
;;
*)
. ${{ github.action_path }}/util/install.sh &>/dev/null
member_id=$(sudo zerotier-cli info | awk '{ print $3 }')
;;
esac
echo "⏁ Authorizing Runner to ZeroTier network"
curl -s -X POST -H "Authorization: token ${{ inputs.auth_token }}" -d '{"config":{"authorized":true}}' "${{ inputs.api_url }}/network/${{ inputs.network_id }}/member/${member_id}"
echo "⏁ Joining ZeroTier Network ID: ${{ inputs.network_id }}"
case $(uname -s) in
MINGW64_NT?*)
"${ztcli}" join ${{ inputs.network_id }}
while ! "${ztcli}" listnetworks | grep ${{ inputs.network_id }} | grep OK ; do sleep 0.5 ; done
;;
*)
sudo zerotier-cli join ${{ inputs.network_id }}
while ! sudo zerotier-cli listnetworks | grep ${{ inputs.network_id }} | grep OK ; do sleep 0.5 ; done
;;
esac
post: |
set -euo pipefail
IFS=$'\n\t'
case $(uname -s) in
MINGW64_NT?*)
ztcli="/c/Program Files (x86)/ZeroTier/One/zerotier-cli.bat"
member_id=$("${ztcli}" info | awk '{ print $3 }')
;;
*)
member_id=$(sudo zerotier-cli info | awk '{ print $3 }')
;;
esac
echo "⏁ Removing Runner from ZeroTier network"
curl -s -X DELETE -H "Authorization: token ${{ inputs.auth_token }}" "${{ inputs.api_url }}/network/${{ inputs.network_id }}/member/${member_id}"