diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml new file mode 100644 index 0000000..45f0153 --- /dev/null +++ b/.github/workflows/hugo.yml @@ -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 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 = "/"