github-action/action.yml
2025-02-13 15:12:51 -07:00

81 lines
3 KiB
YAML

# Copyright (c) Tailscale Inc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause
#
name: 'Connect Tailscale'
description: 'Connect your GitHub Action workflow to Tailscale'
branding:
icon: 'arrow-right-circle'
color: 'gray-dark'
inputs:
authkey:
description: 'Your Tailscale authentication key, from the admin panel.'
required: false
deprecationMessage: 'An OAuth API client https://tailscale.com/s/oauth-clients is recommended instead of an authkey'
oauth-client-id:
description: 'Your Tailscale OAuth Client ID.'
required: false
oauth-secret:
description: 'Your Tailscale OAuth Client Secret.'
required: false
tags:
description: 'Comma separated list of Tags to be applied to nodes. The OAuth client must have permission to apply these tags.'
required: false
version:
description: 'Tailscale version to use. Specify `latest` to use the latest stable version.'
required: true
default: '1.78.1'
sha256sum:
description: 'Expected SHA256 checksum of the tarball.'
required: false
default: ''
args:
description: 'Optional additional arguments to `tailscale up`'
required: false
default: ''
tailscaled-args:
description: 'Optional additional arguments to `tailscaled`'
required: false
default: ''
hostname:
description: 'Fixed hostname to use.'
required: false
default: ''
statedir:
description: 'Optional state directory to use (if unset, memory state is used)'
required: false
default: ''
timeout:
description: 'Timeout for `tailscale up`'
required: false
default: '2m'
runs:
using: 'composite'
steps:
- name: Check Auth Info Empty
if: ${{ inputs.authkey == '' && (inputs['oauth-secret'] == '' || inputs.tags == '') }}
shell: bash
run: |
echo "::error title=⛔ error hint::OAuth identity empty, Maybe you need to populate it in the Secrets for your workflow, see more in https://docs.github.com/en/actions/security-guides/encrypted-secrets and https://tailscale.com/s/oauth-clients"
exit 1
- name: Connect to Tailscale
shell: pwsh
env:
ADDITIONAL_ARGS: ${{ inputs.args }}
HOSTNAME: ${{ inputs.hostname }}
TAILSCALE_AUTHKEY: ${{ inputs.authkey }}
TIMEOUT: ${{ inputs.timeout }}
TS_EXPERIMENT_OAUTH_AUTHKEY: true
run: |
choco install tailscale
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
$hostname = "${{ inputs.hostname }}"
if (-not "${HOSTNAME}" ) {
$hostname ="github-" + $env:computername
}
if ("${{ inputs['oauth-secret'] }}") {
$TAILSCALE_AUTHKEY="${{ inputs['oauth-secret'] }}?preauthorized=true&ephemeral=true"
$TAGS_ARG="--advertise-tags=${{ inputs.tags }}"
}
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
tailscale up $TAGS_ARG --authkey=$TAILSCALE_AUTHKEY --hostname=$HOSTNAME --accept-routes ${{ inputs.args }}