Skip to content

Commit 8e9a7f0

Browse files
committed
ci: fix ci to not pull readme if not modification done + add generate-github command to package
1 parent 9df3d6c commit 8e9a7f0

2 files changed

Lines changed: 62 additions & 18 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,74 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v5
1414

15-
- name: Download latest plugin data
15+
- name: Restore plugin release commit cache
16+
id: cache-commit
17+
uses: actions/cache/restore@v4
18+
with:
19+
path: .plugin-release-commit
20+
key: plugin-release-commit-${{ github.sha }}
21+
restore-keys: |
22+
plugin-release-commit-
23+
24+
- name: Check and download plugin data
25+
id: plugin-data
1626
run: |
17-
echo "Downloading plugin data from latest release..."
18-
curl -L -o plugins-data.zip \
19-
https://github.com/litestar-org/plugins/releases/latest/download/plugins-and-readmes.zip
27+
# Get the latest release commit SHA from the plugins repo
28+
LATEST_COMMIT=$(curl -s https://api.github.com/repos/litestar-org/plugins/releases/latest | jq -r '.target_commitish')
29+
echo "Latest release commit: $LATEST_COMMIT"
30+
31+
# Check if we have a cached commit
32+
if [ -f .plugin-release-commit ]; then
33+
CURRENT_COMMIT=$(cat .plugin-release-commit)
34+
echo "Current cached commit: $CURRENT_COMMIT"
35+
else
36+
CURRENT_COMMIT=""
37+
echo "No cached commit found"
38+
fi
39+
40+
# Compare commits
41+
if [ "$LATEST_COMMIT" = "$CURRENT_COMMIT" ] && [ -n "$CURRENT_COMMIT" ]; then
42+
echo "Plugin data is up to date (commit: $LATEST_COMMIT)"
43+
echo "changed=false" >> $GITHUB_OUTPUT
44+
else
45+
echo "Plugin data needs update (current: $CURRENT_COMMIT, latest: $LATEST_COMMIT)"
46+
echo "changed=true" >> $GITHUB_OUTPUT
47+
48+
echo "Downloading plugin data from latest release..."
49+
curl -L -o plugins-data.zip \
50+
https://github.com/litestar-org/plugins/releases/latest/download/plugins-and-readmes.zip
51+
52+
echo "Extracting plugin data..."
53+
unzip -o plugins-data.zip
2054
21-
echo "Extracting plugin data..."
22-
unzip -o plugins-data.zip
55+
echo "Moving files to content directories..."
56+
# Remove existing plugin files to ensure clean state
57+
rm -rf content/plugins/*.yml content/readme/*.md
2358
24-
echo "Moving files to content directories..."
25-
# Remove existing plugin files to ensure clean state
26-
rm -rf content/plugins/*.yml content/readme/*.md
59+
# Move extracted files to content directories
60+
mv plugins/*.yml content/plugins/
61+
mv readmes/*.md content/readme/
2762
28-
# Move extracted files to content directories
29-
mv plugins/*.yml content/plugins/
30-
mv readmes/*.md content/readme/
63+
# Store the new commit for caching
64+
echo "$LATEST_COMMIT" > .plugin-release-commit
3165
32-
# Clean up
33-
rm -rf plugins readmes plugins-data.zip
66+
# Clean up
67+
rm -rf plugins readmes plugins-data.zip
3468
35-
echo "Plugin data updated successfully"
36-
echo "Plugin count: $(ls -1 content/plugins/*.yml 2>/dev/null | wc -l)"
37-
echo "README count: $(ls -1 content/readme/*.md 2>/dev/null | wc -l)"
69+
echo "Plugin data updated successfully"
70+
echo "Plugin count: $(ls -1 content/plugins/*.yml 2>/dev/null | wc -l)"
71+
echo "README count: $(ls -1 content/readme/*.md 2>/dev/null | wc -l)"
72+
fi
73+
74+
- name: Save plugin release commit cache
75+
if: steps.plugin-data.outputs.changed == 'true'
76+
uses: actions/cache/save@v4
77+
with:
78+
path: .plugin-release-commit
79+
key: plugin-release-commit-${{ github.sha }}
3880

3981
- name: Commit and push plugin data
82+
if: steps.plugin-data.outputs.changed == 'true'
4083
run: |
4184
git config user.name "github-actions[bot]"
4285
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -75,7 +118,7 @@ jobs:
75118
- run: pnpm install --frozen-lockfile
76119
- name: Update stats
77120
run: pnpm run update-stats
78-
- run: pnpm nuxt generate --preset github_pages
121+
- run: pnpm run generate-github
79122
- name: Upload artifact
80123
uses: actions/upload-pages-artifact@v4
81124
with:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"build": "NODE_OPTIONS='--max-old-space-size=8192' nuxt build",
77
"generate": "NODE_OPTIONS='--max-old-space-size=8192' nuxt generate",
8+
"generate-github": "NODE_OPTIONS='--max-old-space-size=8192' nuxt generate --preset github_pages",
89
"generate-verbose": "NODE_OPTIONS='--max-old-space-size=8192' nuxt generate --logLevel=verbose",
910
"dev": "nuxt dev",
1011
"preview": "nuxt preview",

0 commit comments

Comments
 (0)