Merge pull request #1251 from aeternity/master #370
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: SSR deploy | |
on: [push, pull_request] | |
jobs: | |
deploy: | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
env: | |
TARGET: ${{ format('/home/{0}/superhero-ui', secrets.SSR_STAGE_USER) }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 14.x | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- run: npm ci | |
- run: npm run ssr:build | |
- name: Deploy to stage | |
uses: easingthemes/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSR_STAGE_PRIVATE_KEY }} | |
REMOTE_HOST: ${{ secrets.SSR_STAGE_HOST }} | |
REMOTE_USER: ${{ secrets.SSR_STAGE_USER }} | |
SOURCE: . | |
TARGET: ${{ env.TARGET }} | |
EXCLUDE: '/.git/, /node_modules/' | |
- name: Execute SSH commmands on remote server | |
uses: JimCronqvist/action-ssh@master | |
env: | |
NODE_ENV: production | |
HOME: /home/${{ secrets.SSR_STAGE_USER }} | |
NVM_DIR: /home/${{ secrets.SSR_STAGE_USER }}/.nvm | |
TARGET: ${{ env.TARGET }} | |
with: | |
hosts: '${{ secrets.SSR_STAGE_USER }}@${{ secrets.SSR_STAGE_HOST }}' | |
privateKey: ${{ secrets.SSR_STAGE_PRIVATE_KEY }} | |
debug: true | |
command: | | |
source ${{ env.NVM_DIR }}/nvm.sh || exit 1 | |
cd ${{ env.TARGET }} || exit 1 | |
nvm install 14 --latest-npm --no-progress --default || exit 1 | |
npm ci || exit 1 | |
killall node | |
setsid nohup npm run ssr:start </dev/null &2>log.log & | |
disown | |
comment: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: unsplash/comment-on-pr@85a56be792d927ac4bfa2f4326607d38e80e6e60 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
HOST: ${{ secrets.SSR_STAGE_HOST }} | |
with: | |
msg: SSR will be deployed to [${{ env.HOST }}](https://${{ env.HOST }}), [bundle report](https://${{ env.HOST }}/report.html) | |
check_for_duplicate_msg: true |