Skip to content

Merge branch 'Simon-Initiative:master' into master #202

Merge branch 'Simon-Initiative:master' into master

Merge branch 'Simon-Initiative:master' into master #202

Workflow file for this run

name: Package
on:
push:
branches:
- master
- hotfix-*
- prerelease-*
# manually trigger a package build from the Actions tab
workflow_dispatch:
jobs:
package:
runs-on: ubuntu-latest
outputs:
app_version: ${{ steps.info.outputs.app_version }}
sha_short: ${{ steps.info.outputs.sha_short }}
deploy_host: ${{ steps.info.outputs.deploy_host }}
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
echo "deploy_host=$(echo tokamak.oli.cmu.edu)" >> $GITHUB_OUTPUT
echo "workspace=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT
- name: 📦 Package
uses: ./.github/actions/torus-builder
with:
build-sha: ${{ steps.info.outputs.sha_short }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 🗜️ Zip it
run: |
mkdir oli-torus-releases
cd _build/prod/rel/oli
zip -r ../../../../oli-torus-releases/oli-${{ steps.info.outputs.app_version }}-${{ steps.info.outputs.sha_short }}.zip *
- name: ⬆️💽 Upload release to S3 archive
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks
env:
AWS_S3_BUCKET: "oli-torus-releases"
AWS_ACCESS_KEY_ID: ${{ secrets.SIMON_BOT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SIMON_BOT_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "us-east-2"
SOURCE_DIR: "oli-torus-releases"
check-auto-deploy:
name: Check AUTO_DEPLOY_ENABLED config
runs-on: ubuntu-latest
environment: tokamak.oli.cmu.edu
outputs:
enabled: ${{ steps.check_auto_deploy_enabled.outputs.enabled }}
steps:
- name: Check whether AUTO_DEPLOY_ENABLED is set to TRUE
id: check_auto_deploy_enabled
run: echo "enabled=$(if [ "${{ vars.AUTO_DEPLOY_ENABLED }}" == "TRUE" ] ; then echo true ; else echo false ; fi)" >> $GITHUB_OUTPUT
deployment:
runs-on: ubuntu-latest
environment: tokamak.oli.cmu.edu
needs: [package, check-auto-deploy]
if: github.ref == 'refs/heads/master' && needs.check-auto-deploy.outputs.enabled == 'true'
steps:
- run: echo "deploying ${{ github.sha }} ${{ github.ref }} ${{ github.ref_name }} to ${{ needs.package.outputs.deploy_host }}"
- name: 🚢💰 Deploy to test using SSH
uses: fifsky/ssh-action@master
if: ${{ github.ref == 'refs/heads/master' }}
with:
command: |
cd /torus
sh deploy.sh -r ${{ github.ref }} ${{ needs.package.outputs.app_version }} ${{ needs.package.outputs.sha_short }}
host: ${{ needs.package.outputs.deploy_host }}
user: simon-bot
key: ${{ secrets.SIMON_BOT_PRIVATE_KEY}}
port: 44067