forked from tailscale/github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
68 lines (68 loc) · 2.39 KB
/
action.yml
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
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: true
version:
description: 'Tailscale version to use.'
required: true
default: '1.32.1'
args:
description: 'Optional additional arguments to `tailscale up`'
required: false
default: ''
hostname:
description: 'Fixed hostname to use.'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Check Runner OS
if: ${{ runner.os != 'Linux' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Linux Only"
exit 1
- name: Check Auth Key Empty
if: ${{ inputs.authkey == '' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Auth key 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"
exit 1
- name: Download Tailscale
shell: bash
id: download
env:
VERSION: ${{ inputs.version }}
run: |
MINOR=$(echo "$VERSION" | awk -F '.' {'print $2'})
if [ $((MINOR % 2)) -eq 0 ]; then
URL="https://pkgs.tailscale.com/stable/tailscale_${VERSION}_amd64.tgz"
else
URL="https://pkgs.tailscale.com/unstable/tailscale_${VERSION}_amd64.tgz"
fi
curl "$URL" -o tailscale.tgz
tar -C /tmp -xzf tailscale.tgz
rm tailscale.tgz
TSPATH=/tmp/tailscale_${VERSION}_amd64
sudo mv "${TSPATH}/tailscale" "${TSPATH}/tailscaled" /usr/bin
- name: Run Tailscale
shell: bash
env:
TAILSCALE_AUTHKEY: ${{ inputs.authkey }}
ADDITIONAL_ARGS: ${{ inputs.args }}
HOSTNAME: ${{ inputs.hostname }}
run: |
sudo tailscaled 2>~/tailscaled.log &
if [ -z "${HOSTNAME}" ]; then
HOSTNAME="github-$(cat /etc/hostname)"
fi
sudo tailscale up --authkey ${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}