BaseMax / GitHubAction-Jekyll-SFTP-Deploy-Password

This is a guide and template for deploying a Jekyll site by FTP/SFTP to the server with GitHub Actions. Usually, you can easily deploy your Jekyll application in GitHub Pages, but sometimes you need to deploy your site to your own server by FTP/SFTP. This guide will help you to do that.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Actions: Deploy Jekyll to SFTP with password

This is a guide and template for deploying a Jekyll site by FTP/SFTP to the server with GitHub Actions. Usually, you can easily deploy your Jekyll application in GitHub Pages, but sometimes you need to deploy your site to your own server by FTP/SFTP. This guide will help you to do that.

GitHub Actions

GitHub Actions is a service that allows you to run your own scripts on GitHub's infrastructure. You can use it to automate tasks like building and testing your code, or deploying your site to a server.

GitHub Actions are great to use in projects. Happy coding ^_^

Why this one and GitHub Actions?

It took me a few hours to prepare and test this configuration, I'm happy to share this for free to save others time.

Example

Create .github/workflows/deploy.yml file.

You can see an example workflow in the following:

on: [push]

jobs:
  mirror_with_sftp:
    name: deploy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.4' # Not needed with a .ruby-version file
          bundler-cache: true # runs 'bundle install' and caches installed gems automatically

      - name: Bundle install
        env:
          RAILS_ENV: test
        run: |
          bundle install --jobs 4 --retry 3

      - name: 🔨 Build Project
        run: |
          bundle exec jekyll build

      - name: List output files
        run: |
          find ./_site/ -print

      - name: FTP Deployer
        uses: sand4rt/ftp-deployer@v1.4
        with:
          sftp: true
          host: ${{ secrets.SERVER_HOST }}
          port: 22
          username: ${{ secrets.SERVER_USERNAME }}
          password: ${{ secrets.SERVER_PASSWORD }}
          remote_folder: ${{ secrets.SERVER_PATH }}
          local_folder: './_site/'
          cleanup: false
          include: '[ "*", "**/*" ]'
          exclude: '[".htaccess", ".github/**", ".git/**", "*.env"]'
          pasive: true

Note that you need to add your secrets to the repository settings. You need to define the following secrets:

  • SERVER_HOST
  • SERVER_USERNAME
  • SERVER_PASSWORD
  • SERVER_PATH

Show case

I am using this workflow in my personal website, because I want to deploy my site to my own server by FTP/SFTP. You can see the source code of my website in the following: https://github.com/BaseMax/Max

Read more

© Copyright Max Base, 2022

About

This is a guide and template for deploying a Jekyll site by FTP/SFTP to the server with GitHub Actions. Usually, you can easily deploy your Jekyll application in GitHub Pages, but sometimes you need to deploy your site to your own server by FTP/SFTP. This guide will help you to do that.

License:GNU General Public License v3.0