Skip to content

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

Merge branch 'Simon-Initiative:master' into master

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

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:
amazon-linux:
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: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# build (or retrieve from cache) the amazon-linux-builder image, used by the next step to build the release for Amazon Linux 2
- name: 🐳 Build amazon-linux-builder image
uses: docker/build-push-action@v5
with:
context: ./.github/actions/amazon-linux-builder
load: true
push: false
tags: amazon-linux-builder:local
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 📦 Package for Amazon Linux
uses: ./.github/actions/amazon-linux-builder
with:
build-sha: ${{ steps.info.outputs.sha_short }}
- 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"
container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
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@v3
- name: 🔧 Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- 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
- name: 🧾 Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/simon-initiative/oli-torus
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: 🔑 Log in to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# builds the official oli-torus app image
- name: 🐳 Docker Build and Push
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: APP_VERSION=${{ steps.info.outputs.app_version }}
SHA_SHORT=${{ steps.info.outputs.sha_short }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
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: [amazon-linux, 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.amazon-linux.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.amazon-linux.outputs.app_version }} ${{ needs.amazon-linux.outputs.sha_short }}
host: ${{ needs.amazon-linux.outputs.deploy_host }}
user: simon-bot
key: ${{ secrets.SIMON_BOT_PRIVATE_KEY}}
port: 44067