Migrate Pelican Site CI/CD From Travis CI to GitHub Actions
Build and deploy Pelican site using GitHub Actions instead of Travis CI.
My original CI/CD file on Travis CI is:
sudo: required
dist: bionic
language: python
python:
- '3.8'
branches:
only:
- master
addons:
apt:
packages:
- language-pack-en
- language-pack-zh-hant
- language-pack-th
install:
- pip install -r requirements.txt
- make download
script:
- make publish
deploy:
provider: pages
repo: siongui/siongui.github.io
target_branch: master
skip_cleanup: true
github_token: $GITHUB_TOKEN
local_dir: output
on:
branch: master
Summaries of above YAML config:
- Ubuntu machine/Python 3.8
- Install Ubuntu en/zh-hant/th language packs
- Install Pelican and Python packages using pip
- Build Pelican site using Makefile
- Deploy to another repo of GitHub Pages using Personal Access Token.
The following is the corresponding CI/CD file on GitHub Actions:
name: Pelican site CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install language packs
run: sudo apt-get install language-pack-en language-pack-zh-hant language-pack-th
- uses: actions/checkout@v2.3.1
with:
persist-credentials: false
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build site
run: |
make download
make publish
- name: Add nojekyll
run: |
touch ./output/.nojekyll
- name: Deploy
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
REPOSITORY_NAME: siongui/siongui.github.io
BRANCH: master
FOLDER: output
CLEAN: true
Tested on: Ubuntu Linux 20.04, Python 3.8.5, GitHub Actions.
References:
[1] |
[2] | Pelican and GitHub Pages |