From 0324584a05bbe34afa0d207dd40f1e5f0144a679 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:40:10 +0200 Subject: [PATCH 01/10] feat: add github action --- .github/workflows/hugo.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/hugo.yml diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml new file mode 100644 index 0000000..39c5269 --- /dev/null +++ b/.github/workflows/hugo.yml @@ -0,0 +1,16 @@ +name: Hugo + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: hugo + uses: klakegg/actions-hugo@1.0.0 \ No newline at end of file From e8deb03bc28e5c4d7fd0dbe6d61b249ba8bfa283 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:45:59 +0200 Subject: [PATCH 02/10] fix: update hugo version --- .github/workflows/hugo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 39c5269..7362c49 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -13,4 +13,4 @@ jobs: fetch-depth: 0 - name: hugo - uses: klakegg/actions-hugo@1.0.0 \ No newline at end of file + uses: klakegg/actions-hugo@ext-ubuntu-onbuild \ No newline at end of file From 1825d2b4a201af54a2f4f24953e4b75b6d28b846 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:13:22 +0200 Subject: [PATCH 03/10] fix: install hugo on ubuntu-latest --- .github/workflows/hugo.yml | 80 +++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 7362c49..0d418e3 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -1,16 +1,78 @@ -name: Hugo +name: Deploy Hugo site to Pages -on: [push] +on: + # Runs on pushes targeting the default branch + push: + # branches: + # - main + # - master + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +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: + # Build job build: runs-on: ubuntu-latest - + env: + HUGO_VERSION: 0.120.0 steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 + - 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: Setup Pages + id: pages + uses: actions/configure-pages@v4 + - 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 "${{ steps.pages.outputs.base_url }}/" + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./public - - name: hugo - uses: klakegg/actions-hugo@ext-ubuntu-onbuild \ No newline at end of file + # Deployment job + # deploy: + # environment: + # name: github-pages + # url: ${{ steps.deployment.outputs.page_url }} + # runs-on: ubuntu-latest + # needs: build + # steps: + # - name: Deploy to GitHub Pages + # id: deployment + # uses: actions/deploy-pages@v4 From 62e66adf03fe2f058bd074e9046a70b2657dff1b Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:35:00 +0200 Subject: [PATCH 04/10] fix: deploy to the other repo --- .github/workflows/hugo.yml | 48 ++++++++++++++++++++++---------------- config.toml | 11 +++++++++ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 0d418e3..8f371a3 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -1,16 +1,16 @@ -name: Deploy Hugo site to Pages +name: Build and Deploy Hugo site on: # Runs on pushes targeting the default branch push: - # branches: - # - main - # - master + # branches: + # - main + # - master # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +# Sets permissions of the GITHUB_TOKEN permissions: contents: read pages: write @@ -45,9 +45,6 @@ jobs: with: submodules: recursive fetch-depth: 0 - - name: Setup Pages - id: pages - uses: actions/configure-pages@v4 - name: Install Node.js dependencies run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" - name: Build with Hugo @@ -59,20 +56,31 @@ jobs: hugo \ --gc \ --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" + --baseURL "https://hhassen.github.io/" - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-artifact@v4 with: + name: hugo-site path: ./public # Deployment job - # deploy: - # environment: - # name: github-pages - # url: ${{ steps.deployment.outputs.page_url }} - # runs-on: ubuntu-latest - # needs: build - # steps: - # - name: Deploy to GitHub Pages - # id: deployment - # uses: actions/deploy-pages@v4 + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: hugo-site + path: ./public + + - name: Deploy to GitHub Pages repository + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./public + external_repository: hhassen/hhassen.github.io + publish_branch: main + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' + commit_message: 'Deploy from hhassen.github.io_source' diff --git a/config.toml b/config.toml index 689eeaa..8e2fe03 100644 --- a/config.toml +++ b/config.toml @@ -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/" @@ -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 = "/" From b00947caf4ffbdd9c82efbdfee29ac2045a43ce8 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:37:02 +0200 Subject: [PATCH 05/10] fix: use hugo 111.3 --- .github/workflows/hugo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 8f371a3..f1679bb 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -32,7 +32,7 @@ jobs: build: runs-on: ubuntu-latest env: - HUGO_VERSION: 0.120.0 + HUGO_VERSION: 0.111.3 steps: - name: Install Hugo CLI run: | From dd5b7c454d2d99436bf95a6bfda5307fd575ce7c Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:48:59 +0200 Subject: [PATCH 06/10] fix: use HUGO_GITHUB_TOKEN --- .github/workflows/hugo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index f1679bb..0d391ed 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -77,7 +77,7 @@ jobs: - name: Deploy to GitHub Pages repository uses: peaceiris/actions-gh-pages@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + personal_token: ${{ secrets.HUGO_GITHUB_TOKEN }} publish_dir: ./public external_repository: hhassen/hhassen.github.io publish_branch: main From 54b5837bf815ebf83114d9e4e6b802b1ee9ba620 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:12:23 +0200 Subject: [PATCH 07/10] fix: use Master branch --- .github/workflows/hugo.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 0d391ed..c4e2492 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -3,9 +3,8 @@ name: Build and Deploy Hugo site on: # Runs on pushes targeting the default branch push: - # branches: - # - main - # - master + branches: + - master # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -80,7 +79,7 @@ jobs: personal_token: ${{ secrets.HUGO_GITHUB_TOKEN }} publish_dir: ./public external_repository: hhassen/hhassen.github.io - publish_branch: main + 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' From 2de1fab33d6ae94780321fd409cc8723d0987c88 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:19:20 +0200 Subject: [PATCH 08/10] feat: add pull request job --- .github/workflows/hugo.yml | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index c4e2492..2f275cf 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -6,6 +6,11 @@ on: branches: - master + # Runs on pull requests + pull_request: + branches: + - master + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -27,9 +32,48 @@ defaults: 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-validation + 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: @@ -65,6 +109,7 @@ jobs: # Deployment job deploy: runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' needs: build steps: - name: Download artifact From 1f97d42a3f022b9f7152c0fe95279fc7b438f7a8 Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:19:35 +0200 Subject: [PATCH 09/10] feat: update public folder in source repo --- .github/workflows/hugo.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 2f275cf..d4deb39 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -112,6 +112,11 @@ jobs: 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: @@ -128,3 +133,11 @@ jobs: 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 From b469a92b36dbc2f1f71b4ca96a0f87e3968a843b Mon Sep 17 00:00:00 2001 From: hhassen <52817333+hhassen@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:24:14 +0200 Subject: [PATCH 10/10] feat: rename artifact --- .github/workflows/hugo.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index d4deb39..45f0153 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -67,7 +67,7 @@ jobs: - name: Upload validation artifact uses: actions/upload-artifact@v4 with: - name: hugo-site-validation + name: hugo-site-pr-${{ github.event.pull_request.number }}-${{ github.sha }} path: ./public # Build job @@ -103,7 +103,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: hugo-site + name: hugo-site-${{ github.sha }} path: ./public # Deployment job @@ -120,7 +120,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: hugo-site + name: hugo-site-${{ github.sha }} path: ./public - name: Deploy to GitHub Pages repository