Build and Deploy Eleventy via SFTP using Github Actions

  1. Navigate to Repository > Settings > Secrets > New Repository Secret
  2. Set the name as SSH_PRIVATE_KEY
  3. Paste the contents of the key file
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# .github/workflows/build.yaml

name: Build and Deploy PROJECT_NAME

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.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: Install dependencies & build
        run: |
          npm ci
          npm run build:assets
          npm run build:site          
      
      - name: Deploy build
        uses: wlixcc/SFTP-Deploy-Action@v1.2.1
        with:
          username: 'domain.user'
          server: 'server.host'
          ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
          local_path: './dist/*'
          remote_path: 'site_home_dir'
          args: '-o ConnectTimeout=5'

Read Next

I’m running an experiment for better content recommendations. These are the 3 posts that are most likely to be interesting for you:

All content is licensed under CC BY-NC-SA 4.0. Copying is an act of love - please copy!
More cool websites: Prev | Hotline Webring | Next
Built with Hugo
Theme Stack designed by Jimmy