Skip to content

Use azure/cli action for deploy script #54

Use azure/cli action for deploy script

Use azure/cli action for deploy script #54

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
- uses: eskatos/[email protected]
with:
arguments: clean build installDist
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
- name: Azure CLI Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Open Bastion tunnel and deploy
uses: azure/cli@v2
with:
azcliversion: latest
inlineScript: |
SERVER_PORT=5022
ARGS=-avh --delete
USERNAME=risa
SERVER_DESTINATION=/home/risa/r-isa
echo Opening tunnel
az network bastion tunnel --name $BASTION_NAME --resource-group $RESOURCE_GROUP --target-resource-id $RESOURCE_ID --resource-port 22 --port $SERVER_PORT &
echo Wait for bastion tunnel to open
az network bastion wait --created --name $BASTION_NAME --resource-group $RESOURCE_GROUP
echo Upload new libraries
FOLDER=build/install/risa/lib
rsync $ARGS 50022 $GITHUB_WORKSPACE/$FOLDER [email protected]:$SERVER_DESTINATION
echo Upload new binaries
FOLDER=build/install/risa/bin
rsync $ARGS 50022 $GITHUB_WORKSPACE/$FOLDER [email protected]:$SERVER_DESTINATION
echo Upload new configuration
FOLDER=risa.yml
rsync $ARGS 50022 $GITHUB_WORKSPACE/$FOLDER [email protected]:$SERVER_DESTINATION
echo Run internal deploy script
/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'
# - name: Upload new libraries
# uses: urielsalis/rsync-deploy@master
# env:
# DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# SERVER_PORT: 50022
# FOLDER: "build/install/risa/lib"
# ARGS: "-avh --delete"
# SERVER_IP: localhost
# USERNAME: risa
# SERVER_DESTINATION: /home/risa/r-isa
# CLIENT_ID: ${{ secrets.CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
# RESOURCE_ID: ${{ secrets.RESOURCE_ID }}
# RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
# TENANT_ID: ${{ secrets.TENANT_ID }}
# BASTION_NAME: ${{ secrets.BASTION_NAME }}
# - name: Upload new binaries
# uses: urielsalis/rsync-deploy@master
# env:
# DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# SERVER_PORT: 50022
# FOLDER: "build/install/risa/bin"
# ARGS: "-avh --delete"
# SERVER_IP: localhost
# USERNAME: risa
# SERVER_DESTINATION: /home/risa/r-isa
# CLIENT_ID: ${{ secrets.CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
# RESOURCE_ID: ${{ secrets.RESOURCE_ID }}
# RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
# TENANT_ID: ${{ secrets.TENANT_ID }}
# BASTION_NAME: ${{ secrets.BASTION_NAME }}
# - name: Upload new configuration
# uses: urielsalis/rsync-deploy@master
# env:
# DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# SERVER_PORT: 50022
# FOLDER: "risa.yml"
# ARGS: "-avh --delete"
# SERVER_IP: localhost
# USERNAME: risa
# SERVER_DESTINATION: /home/risa/r-isa
# CLIENT_ID: ${{ secrets.CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
# RESOURCE_ID: ${{ secrets.RESOURCE_ID }}
# RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
# TENANT_ID: ${{ secrets.TENANT_ID }}
# BASTION_NAME: ${{ secrets.BASTION_NAME }}
# - name: Run internal deploy script
# uses: urielsalis/azure-bastion-ssh-action@master
# env:
# CLIENT_ID: ${{ secrets.CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
# RESOURCE_ID: ${{ secrets.RESOURCE_ID }}
# RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
# TENANT_ID: ${{ secrets.TENANT_ID }}
# BASTION_NAME: ${{ secrets.BASTION_NAME }}
# with:
# host: localhost
# port: 50022
# user: risa
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# command: |
# /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'
# args: "-tt"