Isolation of FTS to fts
user
#361
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: ZeroTouch | |
"on": | |
pull_request: | |
types: [opened, reopened] | |
push: | |
branches: | |
- "*" | |
paths-ignore: | |
- '**.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# aws: | |
# runs-on: ubuntu-latest | |
# mythic-beasts: | |
# runs-on: ubuntu-latest | |
digitalocean: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
architecture: ['x64'] | |
region: ['nyc1'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up SSH key | |
run: | | |
echo "${{ secrets.DO_SSH_KEY }}" > private_key | |
chmod 600 private_key | |
echo "${{ secrets.DO_SSH_KEY_PUB }}" > public_key | |
chmod 600 public_key | |
- name: Set up doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DO_API_TOKEN }} | |
- name: Extract branch name | |
run: | | |
branch_name=$(git symbolic-ref --short HEAD) | |
echo "BRANCH_NAME=${branch_name}" >> $GITHUB_ENV | |
- name: Create a new droplet | |
id: create_droplet | |
run: | | |
DROPLET_NAME="${{ github.workflow }}-${{ github.job }}-${{ github.run_id }}" | |
DROPLET_JSON=$(doctl compute droplet create $DROPLET_NAME \ | |
--image ubuntu-22-04-x64 \ | |
--size s-1vcpu-1gb \ | |
--region ${{ matrix.region }} \ | |
--ssh-keys ${{ secrets.DO_SSH_FINGERPRINT }} \ | |
--format ID,PublicIPv4 \ | |
--no-header \ | |
--wait \ | |
--output json) | |
echo "$DROPLET_JSON" | |
echo "DROPLET_ID=$(echo "$DROPLET_JSON" | jq '.[].id')" >> $GITHUB_ENV | |
echo "DROPLET_IP=$(echo "$DROPLET_JSON" | jq -r '.[].networks.v4[0].ip_address')" >> $GITHUB_ENV | |
- name: Wait for SSH | |
run: | | |
COUNT=0 | |
RETRIES=40 | |
while [ $COUNT -lt $RETRIES ] | |
do | |
echo "Attempting to connect to $DROPLET_IP as root (attempt $(($COUNT + 1))/$RETRIES)..." | |
ssh -i private_key -o "BatchMode=yes" -o "StrictHostKeyChecking=no" -o "ConnectTimeout=5" "root@$DROPLET_IP" 'echo SSH_READY' && break | |
COUNT=$(($COUNT + 1)) | |
sleep 15 | |
done | |
if [ $COUNT -lt $RETRIES ]; then | |
echo "SSH is ready on $DROPLET_IP" | |
exit 0 | |
else | |
echo "Failed to establish an SSH connection to $DROPLET_IP after $RETRIES attempts" | |
exit 1 | |
fi | |
- name: Checkout the git repository (Main Branch) | |
if: github.ref == 'refs/heads/main' | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i private_key \ | |
root@$DROPLET_IP "bash -s" <<- 'ENDSSH' | |
git clone https://github.com/FreeTAKTeam/FreeTAKHub-Installation.git | |
ENDSSH | |
- name: Checkout the git repository (Development Branches) | |
if: github.ref != 'refs/heads/main' | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i private_key \ | |
root@$DROPLET_IP "bash -s" <<- 'ENDSSH' | |
git clone https://github.com/FreeTAKTeam/FreeTAKHub-Installation.git | |
cd ~/FreeTAKHub-Installation | |
git checkout ${{ env.BRANCH_NAME }} | |
ENDSSH | |
- name: Install the software | |
run: | | |
ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=12 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i private_key \ | |
root@$DROPLET_IP "bash -s" <<- 'ENDSSH' | |
# Adding sleep timer due to background apt-get updates | |
sleep 540 | |
# Execute Zerotouch Installer | |
~/FreeTAKHub-Installation/scripts/easy_install.sh --branch ${{ env.BRANCH_NAME }} | |
ENDSSH | |
- name: Test TAK Port 8087 | |
run: | | |
until nc -zv $DROPLET_IP 8087; do | |
sleep 5 | |
done | |
- name: Test TAK Port 8089 | |
run: | | |
until nc -zv $DROPLET_IP 8089; do | |
sleep 5 | |
done | |
- name: Test REST API Port 19023 | |
run: | | |
until nc -zv $DROPLET_IP 19023; do | |
sleep 5 | |
done | |
- name: Test Web UI Port 5000 | |
run: | | |
until nc -zv $DROPLET_IP 5000; do | |
sleep 5 | |
done | |
- name: Destroy droplet | |
if: always() | |
run: doctl compute droplet delete -f $DROPLET_ID |