Skip to content

Deploy

Deploy #268

Workflow file for this run

name: Deploy
on:
# run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
deploy_target:
description: "Deploy Target"
required: true
default: "tokamak.oli.cmu.edu"
type: choice
options:
- tokamak.oli.cmu.edu
- stellarator.oli.cmu.edu
- heliotron.oli.cmu.edu
- loadtest.oli.cmu.edu
- proton.oli.cmu.edu
# disable auto deploy on tag for now
# push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+' # production release tags vX.Y.Z
# - 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+' # release candidate tags vX.Y.Z-rc1
#
jobs:
authorize-deployment:
runs-on: ubuntu-latest
outputs:
authorized: ${{ steps.check_deployment_authorization.outputs.authorized }}
environment:
name: ${{ github.event.inputs.deploy_target }}
url: ${{ github.event.inputs.deploy_target }}
steps:
- name: Verify user is authorized to deploy to target
id: check_deployment_authorization
run: echo "authorized=$(actor="${{ github.triggering_actor }}"; authorized_users="$AUTHORIZED_DEPLOY_USERS"; [[ -z $authorized_users || $authorized_users =~ (^|,)$actor(,|$) ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
deployment:
runs-on: ubuntu-latest
needs: [authorize-deployment]
if: needs.authorize-deployment.outputs.authorized == 'true'
environment:
name: ${{ github.event.inputs.deploy_target }}
url: ${{ github.event.inputs.deploy_target }}
outputs:
app_version: ${{ steps.info.outputs.app_version }}
sha_short: ${{ steps.info.outputs.sha_short }}
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v2
- name: 🧾 Build info
id: info
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "app_version=$(cat mix.exs | grep version | sed -e 's/.*version: "\(.*\)",/\1/')" >> $GITHUB_OUTPUT
- run: echo "deploying ${{ github.sha }} ${{ github.ref }} ${{ github.ref_name }} to ${{ github.event.inputs.deploy_target }}"
- name: 🚢💰 Deploy using SSH
uses: fifsky/ssh-action@master
with:
command: |
cd /torus
sh deploy.sh -r ${{ github.ref }} ${{ steps.info.outputs.app_version }} ${{ steps.info.outputs.sha_short }}
host: ${{ github.event.inputs.deploy_target }}
user: simon-bot
key: ${{ secrets.SIMON_BOT_PRIVATE_KEY}}
port: 44067