Skip to content

Commit

Permalink
Merge pull request #15 from golfzaptw/chore/document
Browse files Browse the repository at this point in the history
Update document and add check vpn 15 times
  • Loading branch information
golfzaptw authored Nov 26, 2019
2 parents 52ad1e1 + 7e21444 commit 0c2bf82
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 31 deletions.
58 changes: 36 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ This action is a connect ovpn script

[Test.ovpn](./test.ovpn)

## Configuration
## Configuration with With

The following settings must be passed as environment variables as shown in the
example.

| Key | Value | Suggested Type | Required | Default |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------- | --------------- |
| `FILE_OVPN` | Location file open vpn and . | `env` | **Yes** | `./config.ovpn` |
| `PING_URL` | URL for check status vpn connect pass or fail | `env` | **Yes** | `127.0.0.1` |
| `SECRET` | Username password for access vpn`(Encode base 64 before set secret.)`[How to encode base 64 ?](https://www.base64encode.org/). | `secret env` | No | `''` |
| `TLS_KEY` | Tls-crypt for access vpn `(Encode base 64 before set secret.)`[How to encode base 64 ?](https://www.base64encode.org/). | `secret env` | No | `''` |

## Configuration with Env

The following settings must be passed as environment variables as shown in the
example.

| Key | Value | Suggested Type | Required | Default |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------- | ------- |
| `FILE_OVPN` | Location file open vpn and . | `env` | **Yes** | N/A |
| `PING_URL` | URL for check status vpn connect pass or fail | `env` | **Yes** | N/A |
| `CA_CRT` | Certificate for access vpn `(Encode base 64 before set secret.)`[How to encode base 64 ?](https://www.base64encode.org/). | `secret env` | **Yes** | N/A |
| `USER_CRT` | User certificate for access vpn. `(Encode base 64 before set secret.)`[How to encode base 64 ?](https://www.base64encode.org/). | `secret env` | **Yes** | N/A |
| `USER_KEY` | User key for access vpn. `(Encode base 64 before set secret.)`[How to encode base 64 ?](https://www.base64encode.org/). | `secret env` | **Yes** | N/A |
| `USERNAME` | Username for access vpn. | `secret env` | No | N/A |
| `PASSWORD` | Password for access vpn. | `secret env` | No | N/A |
| `TLS_KEY` | Tls-crypt for access vpn `(Encode base 64 before set secret.)`[How to encode base 64 ?](https://www.base64encode.org/). | `secret env` | No | N/A |

## Outputs

Expand All @@ -31,20 +38,27 @@ example.
## Example usage

```yml
- name: Install Open VPN
run: sudo apt-get install openvpn
- name: Connect VPN
uses: golfzaptw/action-connect-ovpn@master
id: connect_vpn
with:
PING_URL: '127.0.0.1'
FILE_OVPN: 'config.ovpn'
CA_CRT: ${{ secrets.CA_CRT}}
USER_CRT: ${{ secrets.USER_CRT }}
USER_KEY: ${{ secrets.USER_KEY }}
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
TLS_KEY: ${{ secrets.TLS_KEY }}
- name: Check Connect VPN
run: echo ${{ steps.connect_vpn.outputs.STATUS }}
connect-open-vpn:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Open VPN
run: sudo apt-get install openvpn
- name: Connect VPN
uses: golfzaptw/action-connect-ovpn@master
id: connect_vpn
with:
PING_URL: '127.0.0.1'
FILE_OVPN: '.github/vpn/config.ovpn'
SECRET: ${{ secrets.SECRET_USERNAME_PASSWORD }}
TLS_KEY: ${{ secrets.TLS_KEY }}
env:
CA_CRT: ${{ secrets.CA_CRT}}
USER_CRT: ${{ secrets.USER_CRT }}
USER_KEY: ${{ secrets.USER_KEY }}
- name: Check Connect VPN
run: echo ${{ steps.connect_vpn.outputs.STATUS }}
- name: kill vpn
if: always()
run: ls -la && sudo killall openvpn
```
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ branding:
icon: 'cast'
color: 'green'
inputs:
SECRET_ACCESS:
SECRET:
description: 'Username and password for access vpn'
required: false
default: ''
Expand All @@ -15,6 +15,7 @@ inputs:
PING_URL:
description: 'For check success or fail'
required: true
default: '127.0.0.1'
FILE_OVPN:
description: 'Location file open vpn'
required: true
Expand Down
7 changes: 3 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ try {
// Get input defined in action metadata file
const pingURL = core.getInput('PING_URL')
const fileOVPN = core.getInput('FILE_OVPN')
const secret = core.getInput('SECRET_ACCESS')
const secret = core.getInput('SECRET')
const tlsKey = core.getInput('TLS_KEY')

if (process.env.CA_CRT == null) {
Expand Down Expand Up @@ -115,11 +115,10 @@ try {

ping.promise
.probe(pingURL, {
timeout: 10,
min_reply: 10,
timeout: 15,
min_reply: 15,
})
.then(function(res) {
console.log(res)
if (res.alive) {
core.info('Connect vpn passed')
core.setOutput('STATUS', true)
Expand Down
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ try {
// Get input defined in action metadata file
const pingURL = core.getInput('PING_URL')
const fileOVPN = core.getInput('FILE_OVPN')
const secret = core.getInput('SECRET_ACCESS')
const secret = core.getInput('SECRET')
const tlsKey = core.getInput('TLS_KEY')

if (process.env.CA_CRT == null) {
Expand Down Expand Up @@ -58,11 +58,10 @@ try {

ping.promise
.probe(pingURL, {
timeout: 10,
min_reply: 10,
timeout: 15,
min_reply: 15,
})
.then(function(res) {
console.log(res)
if (res.alive) {
core.info('Connect vpn passed')
core.setOutput('STATUS', true)
Expand Down

0 comments on commit 0c2bf82

Please sign in to comment.