Dean

Using GitHub Actions to Deploy Jekyll

I’ve recently started using GitHub Actions to run tests for a few of my projects.

This blog post will show how I deploy my Jekyll sites, built on Jekyll, to an SCP server, in my example, my Krystal hosting account.

Here is my actions file:

.github/workflows/build.yml

name: Build
on: [push]

jobs:
  build:
    name: Build & Deploy
    runs-on: ubuntu-20.04

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup Ruby and install gems
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.7
          bundler-cache: true

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: 14
          cache: 'yarn'

      - name: Install packages
        run: yarn install

      - name: Build Jekyll Site
        env:
          JEKYLL_ENV: production
          NODE_ENV: production
        run: bundle exec jekyll build

      - name: Deploy to Endor
        uses: appleboy/scp-action@master
        with:
          host: server.krystal.uk
          username: username
          password: $
          port: 722
          source: "_site"
          target: "sitename.com"
          strip_components: 1
          rm: true

Copyright 2011-2021 Dean (deanpcmad)

Buy me a Coffee