From 74dc75cd2805cb0903357361e99abda03d4edcaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20M=C3=A4gel?= Date: Fri, 3 Nov 2023 11:09:01 +0100 Subject: [PATCH] Add first post 'Deploy a pelican site with GitHub Actions to GitHub Pages' --- content/20231102.Example-Post.md | 43 ------------- ...ite-with-github-actions-to-github-pages.md | 64 +++++++++++++++++++ 2 files changed, 64 insertions(+), 43 deletions(-) delete mode 100644 content/20231102.Example-Post.md create mode 100644 content/20231103.deploy-pelican-site-with-github-actions-to-github-pages.md diff --git a/content/20231102.Example-Post.md b/content/20231102.Example-Post.md deleted file mode 100644 index 2d8cc77..0000000 --- a/content/20231102.Example-Post.md +++ /dev/null @@ -1,43 +0,0 @@ -Title: SSH-Authentifizierung ohne Passwort -Date: 2023-11-02 08:00 -Category: Server -Tags: SSH, Linux, Server -Authors: Toni Mägel -Slug: example-post - -Zugriffscredentials mit `htpasswd` einrichten. - -```bash -echo -n ':' >> /etc/nginx/.htpasswd -openssl passwd -apr1 >> /etc/nginx/.htpasswd -``` - -Anschließend die `nginx`-Konfiguration anpassen und `nginx` neustarten. - -```bash -server { - - [ ... ] - - location / { - try_files $uri $uri/ =404; - auth_basic "Restricted Content"; - auth_basic_user_file /etc/nginx/.htpasswd; - } - -} -``` - -- abc -- asdsa -- asds - -asdsadsa - -1. asasdsad -2. asdsadsa -3. 4qesadsad - -> Dorothy followed her through many of the beautiful rooms in her castle. - -Anschließend die `nginx`-Konfiguration anpassen und `nginx` neustarten. diff --git a/content/20231103.deploy-pelican-site-with-github-actions-to-github-pages.md b/content/20231103.deploy-pelican-site-with-github-actions-to-github-pages.md new file mode 100644 index 0000000..0180051 --- /dev/null +++ b/content/20231103.deploy-pelican-site-with-github-actions-to-github-pages.md @@ -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 +```