Skip to content

Commit

Permalink
Add first post 'Deploy a pelican site with GitHub Actions to GitHub P…
Browse files Browse the repository at this point in the history
…ages'
  • Loading branch information
tmaegel committed Nov 3, 2023
1 parent 86c3d3f commit 74dc75c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 43 deletions.
43 changes: 0 additions & 43 deletions content/20231102.Example-Post.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Title: Deploy a Pelican site with GitHub Actions to GitHub Pages
Date: 2023-11-03 09:49
Category: DevOps
Tags: Pelican, GithubActions, GitHubPages
Authors: Toni Mägel
Slug: deploy-pelican-site-with-github-actions-to-github-pages

This blog is powered by [Pelian](https://getpelican.com/). It is a static site generator that requires no database or server-side logic and generates your website based on the content which is written in `reStructuredText` or `Markdown`.

I host this site with GitHub Pages. So I though its the best choice to automatically deploy my changes (e.g. content or theme/template) and update my site as well on GitHub Pages by using GitHub Actions.

My workflow based on the following GitHub Actions:

- [actions/checkout](https://github.com/actions/checkout)
- [actions/setup-python](https://github.com/actions/setup-python)
- [JamesIves/github-pages-deploy-action](https://github.com/JamesIves/github-pages-deploy-action)

In the first step I checkout my GitHub repository with `actions/checkout` which holds my content and theme data of this site. Afterwards I prepare the python environment to install the needed python dependencies (e.g. `pelican`) to build my site based on the content and the templates. Finally I use the Github action `JamesIves/github-pages-deploy-action` to deploy the build results to GitHub Pages. This Actions takes the build results of `pelican`. In my case from the directory `build` and commit/push these to the corresponding branch (e.g. `gh-pages`).

This results in the following GitHub Actions workflow.

```yaml
name: Deployment

env:
PELICAN_CONTENT_DIR: content
PELICAN_BUILD_DIR: build
PELICAN_CONFIG_FILE: pelicanconf.py

on:
push:
branches:
- main

permissions:
contents: write

jobs:
build:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Build with pelican
run: pelican $PELICAN_CONTENT_DIR -o $PELICAN_BUILD_DIR -s $PELICAN_CONFIG_FILE

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.PELICAN_BUILD_DIR }}
branch: gh-pages
```

0 comments on commit 74dc75c

Please sign in to comment.