3

Migrate Pelican Site CI/CD From Travis CI to GitHub Actions

 1 year ago
source link: http://siongui.github.io/2020/12/02/migrate-pelican-site-ci-cd-from-travis-ci-to-github-actions/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Migrate Pelican Site CI/CD From Travis CI to GitHub Actions

December 02, 2020

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/[email protected]
      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/[email protected]
      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:

[2]Pelican and GitHub Pages


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK