Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Build and Deploy Hugo site

on:
# Runs on pushes targeting the default branch
push:
branches:
- master

# Runs on pull requests
pull_request:
branches:
- master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

# Default to bash
defaults:
run:
shell: bash

jobs:
# Validation job for pull requests
validate:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
env:
HUGO_VERSION: 0.111.3
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Validate Hugo site
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "https://hhassen.github.io/" \
--buildDrafts \
--buildFuture
- name: Upload validation artifact
uses: actions/upload-artifact@v4
with:
name: hugo-site-pr-${{ github.event.pull_request.number }}-${{ github.sha }}
path: ./public

# Build job
build:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
HUGO_VERSION: 0.111.3
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "https://hhassen.github.io/"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: hugo-site-${{ github.sha }}
path: ./public

# Deployment job
deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: build
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
token: ${{ secrets.HUGO_GITHUB_TOKEN }}
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: hugo-site-${{ github.sha }}
path: ./public

- name: Deploy to GitHub Pages repository
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.HUGO_GITHUB_TOKEN }}
publish_dir: ./public
external_repository: hhassen/hhassen.github.io
publish_branch: master
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Deploy from hhassen.github.io_source'

- name: Update public folder in source repository
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add public/
git diff --staged --quiet || git commit -m "Update public folder after deployment [skip ci]"
git push
11 changes: 11 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ description = "Personal website by Hassen Harzallah"
keywords = "homepage, blog, informatics, development, programming"
images = [""]

[author]
name = "Hassen Harzallah"

[taxonomies]
tag = "tags"
category = "categories"


[permalinks]
posts = "/posts/:year/:month/:title/"
Expand All @@ -58,6 +65,10 @@ images = [""]

# Directory name of your blog content (default is `content/posts`)
contentTypeName = "posts"

# Twitter card configuration
twitter = ""

[params.logo]
logoText = "$ cd ~"
logoHomeLink = "/"
Expand Down