From 479a6285485284d2b54340773292107a61fdec07 Mon Sep 17 00:00:00 2001 From: r3drun3 Date: Thu, 14 Dec 2023 10:24:26 +0100 Subject: [PATCH] ci: modify deploy action Signed-off-by: r3drun3 --- .github/workflows/pages-deploy.yml | 73 ++++++++++++++++-------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/.github/workflows/pages-deploy.yml b/.github/workflows/pages-deploy.yml index 1dccadb..e5f14bf 100644 --- a/.github/workflows/pages-deploy.yml +++ b/.github/workflows/pages-deploy.yml @@ -1,64 +1,71 @@ -name: "Build and Deploy" +# Sample workflow for building and deploying a Hugo site to GitHub Pages +name: Deploy Hugo site to Pages + on: + # Runs on pushes targeting the default branch push: branches: - main - - master - paths-ignore: - - .gitignore - - README.md - - LICENSE # 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 one concurrent deployment +# 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: true + cancel-in-progress: false + +# Default to bash +defaults: + run: + shell: bash jobs: + # Build job build: runs-on: ubuntu-latest - + env: + HUGO_VERSION: 0.121.0 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@v3 + uses: actions/checkout@v4 with: + submodules: recursive fetch-depth: 0 - # submodules: true - # If using the 'assets' git submodule from Chirpy Starter, uncomment above - # (See: https://github.com/cotes2020/chirpy-starter/tree/main/assets) - - name: Setup Pages id: pages - uses: actions/configure-pages@v1 - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3 # reads from a '.ruby-version' or '.tools-version' file if 'ruby-version' is omitted - bundler-cache: true - - - name: Build site - run: bundle exec jekyll b -d "_site${{ steps.pages.outputs.base_path }}" + 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: - JEKYLL_ENV: "production" - - - name: Test site + # For maximum backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production run: | - bundle exec htmlproofer _site --disable-external --check-html --allow_hash_href - - - name: Upload site artifact - uses: actions/upload-pages-artifact@v1 + hugo \ + --gc \ + --minify \ + --baseURL "${{ steps.pages.outputs.base_url }}/" + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 with: - path: "_site${{ steps.pages.outputs.base_path }}" + path: ./public + # Deployment job deploy: environment: name: github-pages @@ -68,4 +75,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 \ No newline at end of file + uses: actions/deploy-pages@v3 \ No newline at end of file