We’ve updated the devops docs at https://servoycomponents.com/devops with a new simplified WAR Auto-Deploy example. The example shows how to build the WAR file, and then use OpenVPN to connect securely to your VPN Server, and then SSH into the Tomcat server to stop the service, then upload the WAR, and start the service back up, and finally exit the VPN. This allows you to SSH into your Linux Tomcat server without opening up port 22 to the outside world. Similar options could be done for Windows servers.
Each "- name: " in the YAML below represents a different step in GitHub actions and they chain together to build your custom action/pipeline.
name: "Build and Auto-Deploy"
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '[war]')"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Servoy WAR Build
uses: itechpros/servoy-war-builder@v1
with:
servoy-version: 2023.03.2.3844
api-key: License Key from us
solution-name: MySolution
default-admin-user: admin
default-admin-password: password
dbi: true
extras-folder: ServoyDeveloperExtras
- name: VPN Connect
uses: aduriseti/ovpn3-connect-action@v1
id: connect_vpn
with:
ovpn-config: ${{ secrets.OPENVPN_CONFIG }}
vpn-user: ${{ secrets.OPENVPN_USER }}
vpn-pass: ${{ secrets.OPENVPN_PASS }}
- name: SSH to stop tomcat
uses: tiyee/action-ssh@v1.0.1
with:
host: yourhost.com
port: 22
username: centos
privateKey: ${{ secrets.KEY_PEM }}
command: 'sudo systemctl stop tomcat'
- name: SFTP the war
uses: wlixcc/SFTP-Deploy-Action@v1.2.4
with:
server: yourhost.com
port: 22
username: centos
ssh_private_key: ${{ secrets.KEY_PPM }}
local_path: 'MySolution.war'
remote_path: '/usr/share/tomcat/webapps'
sftp_only: true
- name: SSH to start tomcat
uses: tiyee/action-ssh@v1.0.1
with:
host: yourhost.com
port: 22
username: centos
privateKey: ${{ secrets.KEY_PPM }}
command: 'sudo systemctl start tomcat'
- name: kill vpn
if: always()
run: |
sudo pkill openvpn