Skip to content

Commit eeb7759

Browse files
committed
fix: Fix CI
1 parent 93f2dc0 commit eeb7759

File tree

2 files changed

+92
-3
lines changed

2 files changed

+92
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ name: CI
33
on:
44
pull_request:
55
types:
6-
- opened
7-
- synchronize
8-
- reopened
6+
- closed
97
push:
108
branches:
119
- main
@@ -14,6 +12,7 @@ on:
1412
jobs:
1513
prepare:
1614
runs-on: ubuntu-latest
15+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
1716

1817
outputs:
1918
submodule-matrix: ${{ steps.discover-submodules.outputs.submodule-matrix }}

.github/workflows/pr.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Test Build
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
test-build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
persist-credentials: true
21+
fetch-depth: 0
22+
submodules: recursive
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: '20'
28+
29+
- name: Install pnpm
30+
run: npm install -g pnpm
31+
32+
- name: Install Dependencies
33+
run: |
34+
pnpm install
35+
env:
36+
NODE_ENV: production
37+
38+
- name: Build Plugin
39+
run: |
40+
pnpm run build
41+
env:
42+
NODE_ENV: production
43+
44+
- name: Prepare Distribution Files
45+
run: |
46+
47+
mkdir -p dist
48+
49+
cp -r ".millennium" dist/.millennium 2>/dev/null || echo "::error::.millennium directory not found, it is required to run the plugin."
50+
cp "plugin.json" dist/plugin.json 2>/dev/null || { echo "::error::plugin.json was not found. It is required for plugins to have."; exit 1; }
51+
cp "requirements.txt" dist/requirements.txt 2>/dev/null || echo "::warning::requirements.txt not found, skipping."
52+
cp "README.md" dist/README.md 2>/dev/null || echo "::warning::README.md not found, skipping."
53+
cp "README" dist/README 2>/dev/null || echo "::warning::README not found, skipping."
54+
55+
BACKEND_DIR=$(jq -r '.backend' plugin.json)
56+
if [ "$BACKEND_DIR" != "null" ]; then
57+
cp -r "$BACKEND_DIR" ./dist/"$BACKEND_DIR"
58+
else
59+
cp -r "backend" ./dist/backend 2>/dev/null || echo "::warning::backend directory not found, skipping."
60+
fi
61+
62+
include=$(jq -r '.include // [] | .[]' plugin.json)
63+
64+
if [ -z "$include" ]; then
65+
echo "::notice::No additional files to include."
66+
else
67+
echo "::notice::Including additional files: $include"
68+
for item in $include; do
69+
mkdir -p "./dist/$(dirname "$item")"
70+
cp -r "./$item" "./dist/$item"
71+
done
72+
fi
73+
74+
echo "::notice::Computing plugin metadata..."
75+
echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/metadata.json
76+
77+
id=$(jq -r '.id' dist/metadata.json)
78+
79+
cd dist
80+
echo "::notice::Building plugin archive..."
81+
zip -r build.zip .
82+
83+
echo "::notice::Successfully built plugin."
84+
85+
- name: Upload Plugin
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: build
89+
path: dist/build.zip
90+

0 commit comments

Comments
 (0)