From 0d44c108fec2975d47276d0b1315e42eb00678c4 Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:17:37 +0200 Subject: [PATCH 1/7] Separate build and deploy workflows --- .github/workflows/build.yml | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c50966..8637690 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: npm-build +name: Build and Deploy on: workflow_dispatch: @@ -12,40 +12,44 @@ on: - '**/README.md' jobs: - npm-build: + build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: - node-version: '16.x' + node-version: '16' - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules + uses: actions/cache@v3 with: - # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + ${{ runner.os }}-node- + - name: Install dependencies run: npm install - name: Build run: npm run build + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Deploy to gh-pages - uses: s0/git-publish-subdir-action@develop + uses: s0/git-publish-subdir-action@v3 + with: + folder: dist + branch: gh-pages + repo: ${{ github.repository }} env: - REPO: self - BRANCH: gh-pages - FOLDER: dist GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MESSAGE: "deploy website" \ No newline at end of file From d65e2fef514c119f6aaf89324dfff799ebe6848d Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:22:20 +0200 Subject: [PATCH 2/7] Fix cache issue --- .github/workflows/build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8637690..a8aa60f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,11 +25,16 @@ jobs: - name: Cache node modules uses: actions/cache@v3 + env: + cache-name: cache-node-modules with: + # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node- + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - name: Install dependencies run: npm install From 9e27c8eac115e859d2fd7e57470af6e2664f9ca8 Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:27:37 +0200 Subject: [PATCH 3/7] Use another cache --- .github/workflows/build.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8aa60f..18837b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,18 +23,10 @@ jobs: with: node-version: '16' - - name: Cache node modules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} - name: Install dependencies run: npm install From 5c858d1d49568a28141b70ca8146d3dc170815e9 Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:30:07 +0200 Subject: [PATCH 4/7] Use another cache --- .github/workflows/build.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18837b1..dc5fbe3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,16 @@ jobs: - name: Get npm cache directory id: npm-cache-dir shell: bash - run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + run: echo "dir=$(npm config get cache)" >> $GITHUB_ENV + + - name: Cache node modules + uses: actions/cache@v3 + id: npm-cache + with: + path: ${{ env.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - name: Install dependencies run: npm install From de0821405406e9aba759d94557c2d59469cf6580 Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:33:11 +0200 Subject: [PATCH 5/7] Fix caching --- .github/workflows/build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc5fbe3..cc75239 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,13 +26,12 @@ jobs: - name: Get npm cache directory id: npm-cache-dir shell: bash - run: echo "dir=$(npm config get cache)" >> $GITHUB_ENV + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} - - name: Cache node modules - uses: actions/cache@v3 - id: npm-cache + - uses: actions/cache@v3 + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' with: - path: ${{ env.dir }} + path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- From 7404bae8a6383ccaacc78f3e947652bfd199cec8 Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:34:38 +0200 Subject: [PATCH 6/7] Fix caching --- .github/workflows/build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc75239..53ef319 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,11 +50,10 @@ jobs: uses: actions/checkout@v3 - name: Deploy to gh-pages - uses: s0/git-publish-subdir-action@v3 - with: - folder: dist - branch: gh-pages - repo: ${{ github.repository }} + uses: s0/git-publish-subdir-action@develop env: + REPO: self + BRANCH: gh-pages + FOLDER: dist GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MESSAGE: "deploy website" \ No newline at end of file From b00896ebc8de6c73e3d2f3870c633f05d7025c9b Mon Sep 17 00:00:00 2001 From: Nikita Rusetskii Date: Sun, 28 Jul 2024 12:36:35 +0200 Subject: [PATCH 7/7] Remove deploy job --- .github/workflows/build.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53ef319..8294379 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,13 +42,6 @@ jobs: - name: Build run: npm run build - deploy: - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Deploy to gh-pages uses: s0/git-publish-subdir-action@develop env: