Last active
December 3, 2020 14:13
Draft for Github action to deploy stuff to Digital Ocean droplets
This file contains hidden or 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: 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