2021-02-06 09:41:50 +00:00
|
|
|
name: 'Build Docs'
|
|
|
|
|
|
|
|
inputs:
|
|
|
|
asdf-system:
|
|
|
|
description: 'ASDF system to build system for'
|
|
|
|
required: true
|
|
|
|
qlfile-template:
|
|
|
|
description: "Djula template for qlfile. All environment variables are available in it's context"
|
|
|
|
required: false
|
|
|
|
|
|
|
|
runs:
|
|
|
|
using: composite
|
|
|
|
steps:
|
2021-02-06 09:59:05 +00:00
|
|
|
- name: Install Documentation Builder
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo ::group::Install Documentation Builder
|
2021-02-06 13:16:02 +00:00
|
|
|
|
|
|
|
echo 'github docs-builder 40ants/docs-builder' >> qlfile
|
|
|
|
|
|
|
|
qlot update
|
|
|
|
|
|
|
|
qlot exec ros install docs-builder
|
2021-02-06 09:59:05 +00:00
|
|
|
echo ::endgroup::
|
|
|
|
|
2021-02-06 17:30:14 +00:00
|
|
|
- name: Check inputs
|
|
|
|
run: |
|
|
|
|
if [ -z "${{ secrets.SSH_PASS }}" ]
|
|
|
|
then
|
|
|
|
echo "SSH_PASS needs to be passed in the 'with' field."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "${{ secrets.NGROK_AUTH_TOKEN }}" ]
|
|
|
|
then
|
|
|
|
echo "NGROK_AUTH_TOKEN needs to be passed in the 'with' field."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shell: bash
|
|
|
|
- name: Meet OS specific prerequisites
|
|
|
|
run: |
|
|
|
|
if('${{ runner.os }}' -eq 'Linux')
|
|
|
|
{
|
|
|
|
printf "# Preparing environment..."
|
|
|
|
echo "ngrok-stable-linux-386.zip" > ngrok_zip_name
|
|
|
|
whoami > ssh_user
|
|
|
|
printf " [DONE]\n\n"
|
|
|
|
|
|
|
|
echo "# Change the SSH user password"
|
|
|
|
echo "${{ secrets.SSH_PASS }}`n${{ secrets.SSH_PASS }}" | sudo passwd $(cat ssh_user)
|
|
|
|
}
|
|
|
|
elseif('${{ runner.os }}' -eq 'macOS')
|
|
|
|
{
|
|
|
|
printf "# Preparing environment..."
|
|
|
|
echo "ngrok-stable-darwin-amd64.zip" > ngrok_zip_name
|
|
|
|
echo "root" > ssh_user
|
|
|
|
printf " [DONE]\n\n"
|
|
|
|
|
|
|
|
echo "# Change the SSH user password"
|
|
|
|
echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config >/dev/null
|
|
|
|
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
|
|
|
|
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
|
|
|
|
echo "${{ secrets.SSH_PASS }}`n${{ secrets.SSH_PASS }}" | sudo passwd "root"
|
|
|
|
}
|
|
|
|
elseif('${{ runner.os }}' -eq 'Windows')
|
|
|
|
{
|
|
|
|
printf "# Preparing environment..."
|
|
|
|
echo "ngrok-stable-windows-amd64.zip" > ngrok_zip_name
|
|
|
|
echo $env:UserName > ssh_user
|
|
|
|
printf " [DONE]\n\n"
|
|
|
|
|
|
|
|
echo "# Install SSH server"
|
|
|
|
curl https://dl.bitvise.com/BvSshServer-Inst.exe --output BvSshServer-Inst.exe
|
|
|
|
.\BvSshServer-Inst.exe -acceptEULA -defaultInstance
|
|
|
|
|
|
|
|
printf "# Setting up the SSH server to allow access..."
|
|
|
|
$cfg = new-object -com "BssCfg815.BssCfg815"
|
|
|
|
$cfg.settings.SetDefaults()
|
|
|
|
$cfg.settings.access.SetDefaults()
|
|
|
|
$cfg.settings.access.winGroups.Clear()
|
|
|
|
$cfg.settings.access.winGroups.new.SetDefaults()
|
|
|
|
$cfg.settings.access.winGroups.new.loginAllowed = $true
|
|
|
|
$cfg.settings.access.winGroups.NewCommit()
|
|
|
|
$cfg.settings.Save()
|
|
|
|
printf " [DONE]\n\n"
|
|
|
|
|
|
|
|
echo "# Add Firewall rule to allow inbound TCP connection on local port 22"
|
|
|
|
New-NetFirewallRule -Name ngrok -DisplayName 'ngrok' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
|
|
|
|
|
|
|
echo "# Start the SSH server"
|
|
|
|
net start BvSshServer
|
|
|
|
|
|
|
|
echo "# Change the SSH user password"
|
|
|
|
net user $env:UserName ${{ secrets.SSH_PASS }}
|
|
|
|
}
|
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Install and setup ngrok
|
|
|
|
run: |
|
|
|
|
echo "# Install ngrok"
|
|
|
|
curl https://bin.equinox.io/c/4VmDzA7iaHb/$(cat ngrok_zip_name) --output ngrok.zip
|
|
|
|
unzip ngrok.zip
|
|
|
|
chmod +x ./ngrok
|
|
|
|
echo "# Set ngrok with the given authentification token"
|
|
|
|
./ngrok authtoken ${{ secrets.NGROK_AUTH_TOKEN }}
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Start ngrok
|
|
|
|
run: |
|
|
|
|
printf "# Starting ngrok..."
|
|
|
|
./ngrok tcp 22 --log ".ngrok.log" --region "${{ secrets.NGROK_REGION }}" &
|
|
|
|
printf " [DONE]\n\n"
|
|
|
|
printf "# Waiting for '.ngrok.log' file to be properly generated..."
|
|
|
|
while ! grep -osqE "tcp://(.+)" .ngrok.log;do
|
|
|
|
sleep 1
|
|
|
|
if grep -sq "command failed" .ngrok.log
|
|
|
|
then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
printf " [DONE]\n\n"
|
|
|
|
ssh_string=$(grep -oE "tcp://(.+)" .ngrok.log | sed "s/tcp:\/\//ssh $(cat ssh_user)@/" | sed "s/:/ -p /")
|
|
|
|
continue_path=$(eval echo ~$(cat ssh_user)/continue)
|
|
|
|
time=${{ secrets.NGROK_TIMEOUT }}
|
|
|
|
while [ ! -e $continue_path ] && [ $time -gt 1 ]
|
|
|
|
do
|
|
|
|
echo ""
|
|
|
|
echo "#################"
|
|
|
|
echo "# Connect to this runner using:"
|
|
|
|
echo "#########################################"
|
|
|
|
echo $ssh_string
|
|
|
|
echo "#########################################"
|
|
|
|
echo "#"
|
|
|
|
echo "# Allow workflow to continue using:"
|
|
|
|
echo "#########################################"
|
|
|
|
echo "bash -c \"touch $continue_path\""
|
|
|
|
echo "#########################################"
|
|
|
|
echo "#"
|
|
|
|
echo "# SSH session time left:"
|
|
|
|
echo "########################################"
|
|
|
|
printf '#%-14s%dh:%02dm:%02ds%-14s#\n' '' $(($time/3600)) $(($time%3600/60)) $(($time%60)) ''
|
|
|
|
echo "########################################"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
time=$((time-10))
|
|
|
|
done
|
|
|
|
echo "# SSH session terminated. Allowing workflow to continue..."
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
|
2021-02-06 09:59:05 +00:00
|
|
|
- name: Build Docs
|
2021-02-06 13:41:32 +00:00
|
|
|
id: build-docs
|
2021-02-06 09:59:05 +00:00
|
|
|
shell: bash
|
|
|
|
run: |
|
2021-02-06 13:50:31 +00:00
|
|
|
echo ::group::Build Docs
|
2021-02-06 13:59:46 +00:00
|
|
|
OUTPUT_DIR=`build-docs ${{ inputs.asdf-system }}`
|
2021-02-06 13:41:32 +00:00
|
|
|
|
|
|
|
echo "::set-output name=build-dir::${OUTPUT_DIR}"
|
2021-02-06 13:50:31 +00:00
|
|
|
echo ::endgroup::
|
2021-02-06 13:41:32 +00:00
|
|
|
|
|
|
|
- name: Upload Docs
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2021-02-06 13:50:31 +00:00
|
|
|
echo ::group::Upload Docs
|
2021-02-06 13:41:32 +00:00
|
|
|
BUILD_DIR=${{ steps.build-docs.outputs.build-dir }}
|
|
|
|
|
|
|
|
${{ github.action_path }}/upload.ros "${BUILD_DIR}"
|
2021-02-06 13:50:31 +00:00
|
|
|
echo ::endgroup::
|