Release & Deploy #373
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release & Deploy | |
on: | |
workflow_run: | |
workflows: [test] | |
branches: [master] | |
types: [completed] | |
jobs: | |
ZenProject: | |
permissions: | |
contents: write | |
packages: write | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- name: Install zen-cli | |
run: npm install -g @aidbox/zen-cli | |
- name: Install zen deps | |
run: zen-cli pull-deps | |
- name: Build zen project | |
run: zen-cli zen build zenproject beda-emr | |
- uses: marvinpinto/action-automatic-releases@latest | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: latest | |
title: Development build | |
draft: true | |
files: | | |
zenproject/beda-emr.zip | |
Release: | |
runs-on: ubuntu-latest | |
needs: ZenProject | |
env: | |
BUILD_IMAGE: bedasoftware/fhir-emr:master | |
DISABLE_ESLINT_PLUGIN: true | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Prepare config | |
run: cp shared/src/config.production.ts shared/src/config.ts | |
- name: Prepare index.html | |
run: cp public/index.production.html index.html | |
- name: Install deps | |
run: yarn install --network-concurrency 1 | |
- run: yarn extract | |
- run: yarn compile | |
- run: yarn build | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- run: docker run --rm --privileged tonistiigi/binfmt --install all | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- run: >- | |
docker buildx build --platform linux/arm64,linux/amd64 | |
-f Dockerfile.web.release | |
--push -t ${{ env.BUILD_IMAGE }} . | |
Deploy: | |
if: github.ref == 'refs/heads/master' && ${{ github.event.workflow_run.conclusion == 'success' }} | |
needs: Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Cleanup seeds | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script_stop: true | |
script: rm -rf /root/fhir-emr-master/resources/seeds | |
- name: Deploy to Server | |
uses: easingthemes/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
ARGS: '-rltgoDzvO' | |
SOURCE: './' | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
TARGET: '~/fhir-emr-master' | |
- name: Restart | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script_stop: true | |
script: | | |
cd ~/web | |
make restart | |
echo Current branch is ${{ github.ref }} |