-
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (124 loc) · 4.71 KB
/
Copy pathdeploy.yml
File metadata and controls
141 lines (124 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Deploy to GitHub Pages
on:
workflow_dispatch:
push:
branches:
- main
jobs:
prepare-plugin-data:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Restore plugin release commit cache
id: cache-commit
uses: actions/cache/restore@v4
with:
path: .plugin-release-commit
key: plugin-release-commit-${{ github.sha }}
restore-keys: |
plugin-release-commit-
- name: Check and download plugin data
id: plugin-data
run: |
# Get the latest release commit SHA from the plugins repo
LATEST_COMMIT=$(curl -s https://api.github.com/repos/litestar-org/plugins/releases/latest | jq -r '.target_commitish')
echo "Latest release commit: $LATEST_COMMIT"
# Check if we have a cached commit
if [ -f .plugin-release-commit ]; then
CURRENT_COMMIT=$(cat .plugin-release-commit)
echo "Current cached commit: $CURRENT_COMMIT"
else
CURRENT_COMMIT=""
echo "No cached commit found"
fi
# Compare commits
if [ "$LATEST_COMMIT" = "$CURRENT_COMMIT" ] && [ -n "$CURRENT_COMMIT" ]; then
echo "Plugin data is up to date (commit: $LATEST_COMMIT)"
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Plugin data needs update (current: $CURRENT_COMMIT, latest: $LATEST_COMMIT)"
echo "changed=true" >> $GITHUB_OUTPUT
echo "Downloading plugin data from latest release..."
curl -L -o plugins-data.zip \
https://github.com/litestar-org/plugins/releases/latest/download/plugins-and-readmes.zip
echo "Extracting plugin data..."
unzip -o plugins-data.zip
echo "Moving files to content directories..."
# Remove existing plugin files to ensure clean state
rm -rf content/plugins/*.yml content/readme/*.md
# Move extracted files to content directories
mv plugins/*.yml content/plugins/
mv readmes/*.md content/readme/
# Store the new commit for caching
echo "$LATEST_COMMIT" > .plugin-release-commit
# Clean up
rm -rf plugins readmes plugins-data.zip
echo "Plugin data updated successfully"
echo "Plugin count: $(ls -1 content/plugins/*.yml 2>/dev/null | wc -l)"
echo "README count: $(ls -1 content/readme/*.md 2>/dev/null | wc -l)"
fi
- name: Save plugin release commit cache
if: steps.plugin-data.outputs.changed == 'true'
uses: actions/cache/save@v4
with:
path: .plugin-release-commit
key: plugin-release-commit-${{ github.sha }}
- name: Commit and push plugin data
if: steps.plugin-data.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add content/plugins/*.yml content/readme/*.md
# Only commit if there are changes
if git diff --staged --quiet; then
echo "No changes to plugin data"
else
git commit -m "chore: update plugin data from latest release [skip ci]"
git push
echo "Plugin data committed and pushed to main"
fi
- name: Upload workspace
uses: actions/upload-artifact@v4
with:
name: workspace-with-plugins
path: .
build:
needs: prepare-plugin-data
runs-on: ubuntu-latest
steps:
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: workspace-with-plugins
path: .
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: '22'
# Pick your own package manager and build script
- run: pnpm install --frozen-lockfile
- name: Update stats
run: pnpm run update-stats
- run: pnpm run generate-github
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./.output/public
# Deployment job
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4