2020-04-28 09:26:24 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2020-10-03 17:04:08 +00:00
|
|
|
- master
|
2020-04-28 09:26:24 +00:00
|
|
|
|
|
|
|
name: Test
|
|
|
|
jobs:
|
|
|
|
install:
|
|
|
|
runs-on: ubuntu-latest
|
2020-04-28 13:25:14 +00:00
|
|
|
if: github.repository == 'angristan/openvpn-install' && github.actor == 'angristan'
|
2020-04-28 09:26:24 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os-image:
|
|
|
|
- debian-10-x64
|
2022-01-07 15:03:31 +00:00
|
|
|
- debian-11-x64
|
2021-02-14 10:06:57 +00:00
|
|
|
- ubuntu-18-04-x64
|
2020-04-28 09:26:24 +00:00
|
|
|
- ubuntu-20-04-x64
|
2023-01-21 23:06:51 +00:00
|
|
|
- ubuntu-22-04-x64
|
2022-01-07 15:03:31 +00:00
|
|
|
- fedora-35-x64
|
2023-01-21 23:57:26 +00:00
|
|
|
# - fedora-36-x64
|
|
|
|
# - fedora-37-x64
|
|
|
|
# dnf is broken: https://ask.fedoraproject.org/t/dnf-operations-use-large-amount-of-ram-and-may-fail-in-low-memory-environments/26427
|
2020-04-28 09:26:24 +00:00
|
|
|
- centos-7-x64
|
2022-01-24 20:02:46 +00:00
|
|
|
- centos-stream-8-x64
|
2023-01-21 23:57:26 +00:00
|
|
|
- centos-stream-9-x64
|
2020-04-28 09:26:24 +00:00
|
|
|
steps:
|
2023-01-03 13:05:14 +00:00
|
|
|
- uses: actions/checkout@v3.2.0
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Setup doctl
|
|
|
|
uses: digitalocean/action-doctl@v2
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Create server
|
|
|
|
run: doctl compute droplet create openvpn-action-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-${{ matrix.os-image }} --size s-1vcpu-1gb --image ${{ matrix.os-image }} --region lon1 --enable-ipv6 --ssh-keys be:66:76:61:a8:71:93:aa:e3:19:ba:d8:0d:d2:2d:d4 --wait
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Get server ID
|
|
|
|
run: echo ::set-output name=value::$(doctl compute droplet list -o json | jq -r '.[] | select(.name == "'openvpn-action-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-${{ matrix.os-image }}'").id')
|
|
|
|
id: server_id
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Move server to dedicated project
|
|
|
|
run: doctl projects resources assign ${{ secrets.DIGITALOCEAN_PROJECT_ID }} --resource=do:droplet:${{ steps.server_id.outputs.value }}
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Wait for server to boot
|
|
|
|
run: sleep 90
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Get server IP
|
|
|
|
run: echo ::set-output name=value::$(doctl compute droplet list -o json | jq -r '.[] | select(.name == "'openvpn-action-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-${{ matrix.os-image }}'").networks.v4 | .[] | select(.type == "'public'").ip_address')
|
|
|
|
id: server_ip
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Get server OS
|
|
|
|
run: echo ::set-output name=value::$(echo ${{ matrix.os-image }} | cut -d '-' -f1)
|
|
|
|
id: server_os
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Setup remote server (Debian/Ubuntu)
|
|
|
|
if: steps.server_os.outputs.value == 'debian' || steps.server_os.outputs.value == 'ubuntu'
|
2023-01-03 13:05:27 +00:00
|
|
|
uses: appleboy/ssh-action@v0.1.6
|
2020-10-03 17:04:08 +00:00
|
|
|
with:
|
|
|
|
host: ${{ steps.server_ip.outputs.value }}
|
|
|
|
username: root
|
|
|
|
key: ${{ secrets.SSH_KEY }}
|
|
|
|
script: set -x && apt-get update && apt-get install -y git
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Setup remote server (Fedora)
|
|
|
|
if: steps.server_os.outputs.value == 'fedora'
|
2023-01-03 13:05:27 +00:00
|
|
|
uses: appleboy/ssh-action@v0.1.6
|
2020-10-03 17:04:08 +00:00
|
|
|
with:
|
|
|
|
host: ${{ steps.server_ip.outputs.value }}
|
|
|
|
username: root
|
|
|
|
key: ${{ secrets.SSH_KEY }}
|
|
|
|
script: set -x && dnf install -y git
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Setup remote server (CentOS)
|
|
|
|
if: steps.server_os.outputs.value == 'centos'
|
2023-01-03 13:05:27 +00:00
|
|
|
uses: appleboy/ssh-action@v0.1.6
|
2020-10-03 17:04:08 +00:00
|
|
|
with:
|
|
|
|
host: ${{ steps.server_ip.outputs.value }}
|
|
|
|
username: root
|
|
|
|
key: ${{ secrets.SSH_KEY }}
|
|
|
|
script: set -x && yum install -y git
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Download repo and checkout current commit
|
2023-01-03 13:05:27 +00:00
|
|
|
uses: appleboy/ssh-action@v0.1.6
|
2020-10-03 17:04:08 +00:00
|
|
|
with:
|
|
|
|
host: ${{ steps.server_ip.outputs.value }}
|
|
|
|
username: root
|
|
|
|
key: ${{ secrets.SSH_KEY }}
|
2023-01-21 23:06:05 +00:00
|
|
|
script: set -x && git clone https://github.com/angristan/openvpn-install.git && cd openvpn-install && git checkout ${{ github.sha }}
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Run openvpn-install.sh in headless mode
|
2023-01-03 13:05:27 +00:00
|
|
|
uses: appleboy/ssh-action@v0.1.6
|
2020-10-03 17:04:08 +00:00
|
|
|
with:
|
|
|
|
host: ${{ steps.server_ip.outputs.value }}
|
|
|
|
username: root
|
|
|
|
key: ${{ secrets.SSH_KEY }}
|
|
|
|
script: 'set -x && AUTO_INSTALL=y bash -x ~/openvpn-install/openvpn-install.sh && ps aux | grep openvpn | grep -v grep > /dev/null 2>&1 && echo "Success: OpenVPN is running" && exit 0 || echo "Failure: OpenVPN is not running" && exit 1'
|
2020-04-28 09:26:24 +00:00
|
|
|
|
2020-10-03 17:04:08 +00:00
|
|
|
- name: Delete server
|
|
|
|
run: doctl compute droplet delete -f openvpn-action-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-${{ matrix.os-image }}
|
|
|
|
if: always()
|