Skip to content

Run commands over ssh #72

Run commands over ssh

Run commands over ssh #72

Workflow file for this run

# This workflow will build a Java project with Gradle and deploy it
name: Build and push
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Gradle
uses: eskatos/[email protected]
with:
arguments: clean build installDist
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- run: |
python3 -m pip install --upgrade pip --user
az extension add --name bastion
ARGS="-avh --delete"
USERNAME=risa
SERVER_DESTINATION=/home/risa/r-isa
echo Setting up SSH key
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo Opening tunnel
az network bastion tunnel --name ${{ secrets.BASTION_NAME }} --resource-group ${{ secrets.RESOURCE_GROUP }} --target-resource-id ${{ secrets.RESOURCE_ID }} --resource-port 22 --port 50022 &
echo Wait for bastion tunnel to open
az network bastion wait --created --name ${{ secrets.BASTION_NAME }} --resource-group ${{ secrets.RESOURCE_GROUP }}
echo Upload new libraries
FOLDER=build/install/risa/lib
rsync $ARGS -e 'ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -p 50022' $GITHUB_WORKSPACE/$FOLDER [email protected]:$SERVER_DESTINATION
echo Upload new binaries
FOLDER=build/install/risa/bin
rsync $ARGS -e 'ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -p 50022' $GITHUB_WORKSPACE/$FOLDER [email protected]:$SERVER_DESTINATION
echo Upload new configuration
FOLDER=risa.yml
rsync $ARGS -e 'ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -p 50022' $GITHUB_WORKSPACE/$FOLDER [email protected]:$SERVER_DESTINATION
echo Run internal deploy script
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -p 50022 [email protected]:$SERVER_DESTINATION << EOF
/usr/bin/screen -ls | /bin/egrep 'Detached|Attached' | /usr/bin/cut -d. -f1 | /usr/bin/awk '{print $1}' | /usr/bin/xargs /bin/kill
sleep 1
cd r-isa
/usr/bin/screen -d -m bash -c '/home/risa/r-isa/bin/risa; exec sh'
EOF