From 4072e7093770f37b32484a45568cdc36f855ef72 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Thu, 1 May 2025 09:32:14 +0700 Subject: [PATCH] feat: update cache in github action build --- .../workflows/{deploy-pages.yml => hugo.yml} | 34 +++++++++---------- config/_default/caches.yml | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) rename .github/workflows/{deploy-pages.yml => hugo.yml} (72%) create mode 100644 config/_default/caches.yml diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/hugo.yml similarity index 72% rename from .github/workflows/deploy-pages.yml rename to .github/workflows/hugo.yml index 9246213..06c1a5e 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/hugo.yml @@ -1,12 +1,9 @@ -name: Deploy site to GitHub Pages +name: Deploy Hugo site to Pages on: push: branches: - main - pull_request: - branches: - - main workflow_dispatch: @@ -28,6 +25,8 @@ jobs: runs-on: ubuntu-latest env: HUGO_VERSION: 0.140.2 + HUGO_ENVIRONMENT: production + TZ: Asia/Ho_Chi_Minh steps: - name: Install Hugo CLI run: | @@ -41,30 +40,31 @@ jobs: - name: Setup Pages id: pages uses: actions/configure-pages@v5 - - name: Restore resources + - name: Cache Restore + id: cache-restore uses: actions/cache/restore@v4 with: path: | - resources - key: ${{ runner.os }}-resources-${{ github.run_id }} - restore-keys: | - ${{ runner.os }}-resources- + ${{ runner.temp }}/hugo_cache + key: hugo-${{ github.run_id }} + restore-keys: + hugo- + - name: Configure Git + run: git config core.quotepath false - name: Build with Hugo - env: - HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache - HUGO_ENVIRONMENT: production - TZ: Asia/Ho_Chi_Minh run: | hugo \ --gc \ --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" - - name: Save resources + --baseURL "${{ steps.pages.outputs.base_url }}/" \ + --cacheDir "${{ runner.temp }}/hugo_cache" + - name: Cache Save + id: cache-save uses: actions/cache/save@v4 with: path: | - resources - key: ${{ runner.os }}-resources-${{ github.run_id }} + ${{ runner.temp }}/hugo_cache + key: ${{ steps.cache-restore.outputs.cache-primary-key }} - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/config/_default/caches.yml b/config/_default/caches.yml new file mode 100644 index 0000000..4805aac --- /dev/null +++ b/config/_default/caches.yml @@ -0,0 +1,2 @@ +images: + dir: :cacheDir/images