Skip to content

Instantly share code, notes, and snippets.

@manuelgeek
Created February 2, 2021 12:11
Show Gist options
  • Save manuelgeek/a0610de21ac341f2d2e1c8afea7c98d6 to your computer and use it in GitHub Desktop.
Save manuelgeek/a0610de21ac341f2d2e1c8afea7c98d6 to your computer and use it in GitHub Desktop.
Github Actions deploy Nuxt/Quasar SSR
name: Deploy to Staging
on:
push:
branches:
- dev
jobs:
tests-and-lints:
name: Tests and Lints
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint
- run: npm run test:unit
build:
name: Build App Assets
runs-on: ubuntu-latest
needs: tests-and-lints
strategy:
matrix:
node-version: [ 12.x ]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm ci
- name: Create .env
shell: bash
run: |
cp .env.example .env.production
sed -ri 's~^APP_NAME=~APP_NAME="${{ secrets.APP_NAME }}"~' .env.production
- name: Build
run: npm run build:ssr
- name: Upload build files
uses: actions/upload-artifact@v1
with:
name: assets
path: dist
deploy:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [build, tests-and-lints]
steps:
- uses: actions/checkout@v1
- name: Download build assets
uses: actions/download-artifact@v1
with:
name: assets
path: dist
- name: Deploy
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
REMOTE_PORT: ${{ secrets.DEPLOY_PORT }}
SOURCE: "dist/ssr/"
TARGET: "/var/www/frontend"
- name: Performing after deployment scripts
uses: fifsky/ssh-action@master
with:
command: |
cd /var/www/frontend || exit
npm install
pm2 start index.js
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY}}
port: ${{ secrets.DEPLOY_PORT }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment