Skip to content

Commit d9163c2

Browse files
fix(docs): streamline tar creation and extraction process in workflow
1 parent a1fbafc commit d9163c2

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

.github/workflows/docs.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: PUBLISH DOCS
22

33
on:
44
release:
5-
types: [ published ]
5+
types: [published]
66
workflow_dispatch:
77
workflow_call:
88

@@ -21,9 +21,10 @@ jobs:
2121

2222
- name: tar the existing docs
2323
run: |
24-
mkdir -p ./docs
25-
if [ -d "./docs" ] && [ "$(ls -A ./docs)" ]; then
26-
tar -cvf documentation.tar ./docs
24+
# On gh-pages branch, docs are in root directory, not in ./docs folder
25+
if [ "$(ls -A . | grep -v '\.git' | wc -l)" -gt 0 ]; then
26+
# Exclude .git directory and create tar of all documentation files
27+
tar -cvf documentation.tar --exclude='.git' .
2728
else
2829
# Create empty tar if no existing docs
2930
tar -cvf documentation.tar --files-from /dev/null
@@ -45,7 +46,10 @@ jobs:
4546
with:
4647
fetch-depth: 0 # Fetch all history for proper version management
4748

48-
- run: mkdir -p ./docs
49+
- name: Clean docs directory
50+
run: |
51+
rm -rf ./docs
52+
mkdir -p ./docs
4953
5054
- name: Download the existing documents artifact
5155
uses: actions/download-artifact@v4
@@ -55,7 +59,8 @@ jobs:
5559
- name: Extract existing docs
5660
run: |
5761
if [ -f documentation.tar ]; then
58-
tar -xf documentation.tar || echo "No existing documentation to extract"
62+
# Extract existing docs to the docs directory
63+
tar -xf documentation.tar -C ./docs || echo "No existing documentation to extract"
5964
fi
6065
6166
- name: Setup Node.js
@@ -74,15 +79,14 @@ jobs:
7479
run: npm run docs
7580

7681
- name: tar the new docs
77-
run: tar -cvf newdocumentation.tar ./docs
82+
run: tar -cvf newdocumentation.tar -C ./docs .
7883

7984
- name: create a new document artifact
8085
uses: actions/upload-artifact@v4
8186
with:
8287
name: newdocumentation
8388
path: newdocumentation.tar
8489
retention-days: 1
85-
retention-days: 1
8690

8791
commit: # commit the old and new merged documents to gh-pages/docs
8892
needs: build
@@ -118,17 +122,18 @@ jobs:
118122
run: |
119123
# Clear existing content but keep .git
120124
find . -maxdepth 1 ! -name '.git' ! -name '.' -exec rm -rf {} + 2>/dev/null || true
121-
122-
# Extract new documentation
125+
126+
# Extract new documentation directly to root
127+
# The tar now contains the docs contents without the docs/ wrapper
123128
tar -xf newdocumentation.tar
124-
129+
125130
# Configure git
126131
git config --global user.email "github-actions[bot]@users.noreply.github.com"
127132
git config --global user.name "github-actions[bot]"
128-
133+
129134
# Add and commit changes
130135
git add .
131-
136+
132137
# Only commit if there are changes
133138
if ! git diff --staged --quiet; then
134139
git commit -m "CI updated the documentation - ${{ github.sha }}"

scripts/fix-versions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const VERSIONS_JS_FILE = path.join(DOCS_DIR, 'versions.js');
2525
* Get current version from package.json
2626
*/
2727
function getCurrentVersion() {
28-
const packageJsonPath = path.join(__dirname, '../package.json');
29-
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
30-
return packageJson.version;
28+
const packageJsonPath = path.join(__dirname, '../package.json');
29+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
30+
return packageJson.version;
3131
}
3232

3333
/**

0 commit comments

Comments
 (0)