forked from JosiahSiegel/action-connect-ovpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
64 lines (62 loc) · 1.76 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
name: 'Connect-VPN-action'
description: 'Connect VPN action'
branding:
icon: 'shield'
color: 'orange'
inputs:
SECRET:
description: 'Username and password for access vpn'
required: false
default: ''
TLS_KEY:
description: 'User key for access vpn'
required: false
default: ''
PING_URL:
description: 'For check success or fail'
required: true
default: '127.0.0.1'
FILE_OVPN:
description: 'Location file open vpn'
required: true
default: './config.ovpn'
outputs:
STATUS:
description: 'Status for check connect vpn'
value: ${{ steps.vpn_status.outputs.vpn-status }}
runs:
using: "composite"
steps:
- name: Install OpenVPN
run: |
sudo apt-get update
sudo apt-get install openvpn
sudo apt-get install openvpn-systemd-resolved
shell: bash
- name: Connect VPN
env:
TLS_KEY: ${{ inputs.TLS_KEY }}
CA_CRT: ${{ env.CA_CRT}}
USER_CRT: ${{ env.USER_CRT }}
USER_KEY: ${{ env.USER_KEY }}
SECRET: ${{ inputs.SECRET }}
shell: bash
run: |
echo "$TLS_KEY" | base64 -d > tls.key
echo "$CA_CRT" | base64 -d > ca.crt
echo "$USER_CRT" | base64 -d > user.crt
echo "$USER_KEY" | base64 -d > user.key
echo "$SECRET" | base64 -d > secret.txt
sudo openvpn --config ${{ inputs.FILE_OVPN }} --ca ca.crt --cert user.crt --key user.key --tls-crypt tls.key --askpass secret.txt --daemon
- name: VPN Status
id: vpn_status
env:
PING_URL: ${{ inputs.PING_URL }}
shell: bash
run: |
sleep 5
if ping -c 2 $PING_URL > /dev/null 2>&1; then
echo "vpn-status=true" >> $GITHUB_OUTPUT
else
echo "vpn-status=false" >> $GITHUB_OUTPUT
fi