Skip to content

Instantly share code, notes, and snippets.

@educkf
Last active December 3, 2020 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save educkf/6e47da30b5d3ba4e5064cc6ac1fdbf67 to your computer and use it in GitHub Desktop.
Save educkf/6e47da30b5d3ba4e5064cc6ac1fdbf67 to your computer and use it in GitHub Desktop.
Draft for Github action to deploy stuff to Digital Ocean droplets
name: Deploy to D.O. subfolder project
on:
push:
branches:
- staging
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@staging
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Cache dependencies
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 generate
- name: Deploy website to digital ocean
uses: appleboy/scp-action@master
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.KEY }}
with:
source: "./dist"
target: "/path/on/server"
strip_components: 1
- name: Start Server
uses: appleboy/ssh-action@master
with:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.KEY }}
script: |
cd /var/www/${{ secrets.PROJECT }}
git pull origin master
pm2 reload ${{ secrets.PROJECT_URL }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment