DEV Community

es404020
es404020

Posted on

Gastby js deployment to SSH server using Github action.

This is a simple code snippet that shows how you can deploy you Gatsby.js application to an SSH server using Github actions.

Create a main.yaml in your .github/workflow


name: blog
on:
  push:
    branches: main
jobs:
  build-and-deploy:
    name: Build and deploy Gatsby site
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2.3.1

      - name: Install Node.js
        uses: actions/setup-node@v1
        with:
          node-version: '13.x'

      - name: Install Project Dependencies
        run: npm install

      - name: Install Gatsby CLI
        run: npm install -g gatsby-cli@2.12.34

      - name: Build
        run: gatsby build --prefix-paths

      - name: Verify build
        run: ls -la public

      - name: copy file via ssh key
        uses: appleboy/scp-action@master
        env:
          HOST:  
          PORT:  
          USERNAME:  
          PASSWORD: 
        with:
          source: "./public"
          target: "/var/www/html/blog"
          strip_components: 2 # this is important






Enter fullscreen mode Exit fullscreen mode

Top comments (0)