Skip to content

Commit 0c418f5

Browse files
authored
Update build-and-deploy.yml
1 parent 0b6baed commit 0c418f5

File tree

1 file changed

+70
-69
lines changed

1 file changed

+70
-69
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -34,75 +34,76 @@ jobs:
3434
fi
3535
3636
build:
37-
runs-on: ubuntu-latest
38-
needs: determine-environment
39-
environment: ${{ needs.determine-environment.outputs.environment }}
40-
permissions:
41-
contents: read
42-
env:
43-
APP_EXTERNAL_URL: ${{ secrets.APP_EXTERNAL_URL || vars.APP_EXTERNAL_URL }}
44-
steps:
45-
- name: Check out source code
46-
uses: actions/checkout@v4
47-
48-
- name: Set up Node.js
49-
uses: actions/setup-node@v3
50-
with:
51-
node-version: '22.x'
52-
53-
# ✅ START OF THE FIX
54-
- name: Get npm cache directory
55-
id: npm-cache-dir
56-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
57-
58-
- name: Cache Node.js dependencies
59-
uses: actions/cache@v3
60-
with:
61-
path: ${{ steps.npm-cache-dir.outputs.dir }}
62-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
63-
restore-keys: |
64-
${{ runner.os }}-node-
65-
# ✅ END OF THE FIX
66-
67-
- name: Cache Docusaurus build
68-
uses: actions/cache@v3
69-
id: cache-build
70-
with:
71-
path: |
72-
.docusaurus
73-
key: ${{ runner.os }}-docusaurus-${{ hashFiles('src/**', 'docs/**', 'blog/**', 'docusaurus.config.js', 'sidebars.js') }}
74-
restore-keys: |
75-
${{ runner.os }}-docusaurus-
76-
77-
- name: Cache webpack
78-
uses: actions/cache@v3
79-
with:
80-
path: node_modules/.cache
81-
key: ${{ runner.os }}-webpack-${{ hashFiles('**/package-lock.json') }}
82-
restore-keys: |
83-
${{ runner.os }}-webpack-
84-
85-
- name: Install dependencies and build site
86-
run: |
87-
npm ci
88-
89-
if [[ "${{ steps.cache-build.outputs.cache-hit }}" == "true" ]]; then
90-
echo "Build cache found, checking if rebuild needed..."
91-
else
92-
echo "No build cache found, performing full build..."
93-
fi
94-
95-
npm run build
96-
env:
97-
NODE_OPTIONS: "--max-old-space-size=8192"
98-
NODE_ENV: ${{ needs.determine-environment.outputs.environment }}
99-
100-
- name: Upload artifact for deployment
101-
uses: actions/upload-artifact@v4
102-
with:
103-
name: build-output
104-
path: build/
105-
37+
runs-on: ubuntu-latest
38+
needs: determine-environment
39+
environment: ${{ needs.determine-environment.outputs.environment }}
40+
permissions:
41+
contents: read
42+
env:
43+
APP_EXTERNAL_URL: ${{ secrets.APP_EXTERNAL_URL || vars.APP_EXTERNAL_URL }}
44+
steps:
45+
- name: Check out source code
46+
uses: actions/checkout@v4
47+
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v3
50+
with:
51+
node-version: '22.x'
52+
53+
- name: Get npm cache directory
54+
id: npm-cache-dir
55+
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
56+
57+
- name: Cache Node.js dependencies
58+
uses: actions/cache@v3
59+
with:
60+
path: ${{ steps.npm-cache-dir.outputs.dir }}
61+
# ✅ KEY UPDATED
62+
key: v2-${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
63+
restore-keys: |
64+
v2-${{ runner.os }}-node-
65+
66+
- name: Cache Docusaurus build
67+
uses: actions/cache@v3
68+
id: cache-build
69+
with:
70+
path: |
71+
.docusaurus
72+
# ✅ KEY UPDATED
73+
key: v2-${{ runner.os }}-docusaurus-${{ hashFiles('src/**', 'docs/**', 'blog/**', 'docusaurus.config.js', 'sidebars.js') }}
74+
restore-keys: |
75+
v2-${{ runner.os }}-docusaurus-
76+
77+
- name: Cache webpack
78+
uses: actions/cache@v3
79+
with:
80+
path: node_modules/.cache
81+
# ✅ KEY UPDATED
82+
key: v2-${{ runner.os }}-webpack-${{ hashFiles('**/package-lock.json') }}
83+
restore-keys: |
84+
v2-${{ runner.os }}-webpack-
85+
86+
- name: Install dependencies and build site
87+
run: |
88+
npm ci
89+
90+
if [[ "${{ steps.cache-build.outputs.cache-hit }}" == "true" ]]; then
91+
echo "Build cache found, checking if rebuild needed..."
92+
else
93+
echo "No build cache found, performing full build..."
94+
fi
95+
96+
npm run build
97+
env:
98+
NODE_OPTIONS: "--max-old-space-size=8192"
99+
NODE_ENV: ${{ needs.determine-environment.outputs.environment }}
100+
101+
- name: Upload artifact for deployment
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: build-output
105+
path: build/
106+
106107
deploy:
107108
runs-on: ubuntu-latest
108109
needs: [build, determine-environment]

0 commit comments

Comments
 (0)