-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first post 'Deploy a pelican site with GitHub Actions to GitHub P…
…ages'
- Loading branch information
Showing
2 changed files
with
64 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
content/20231103.deploy-pelican-site-with-github-actions-to-github-pages.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |