-
Notifications
You must be signed in to change notification settings - Fork 56
164 lines (137 loc) · 4.94 KB
/
Copy pathci.yml
File metadata and controls
164 lines (137 loc) · 4.94 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: CI
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ci-build
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
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)
outputs:
submodule-matrix: ${{ steps.discover-submodules.outputs.submodule-matrix }}
has-submodules: ${{ steps.discover-submodules.outputs.has-submodules }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: true
fetch-depth: 0
- name: Upload Build Scripts
uses: actions/upload-artifact@v4
with:
name: build-scripts
path: scripts/build/
retention-days: 1
- name: Determine changed plugins
id: changed-plugins
env:
BEFORE: ${{ github.event.before }}
AFTER: ${{ github.event.after }}
run: |
set -euo pipefail
zero_sha="0000000000000000000000000000000000000000"
if [[ "${{ github.event_name }}" != "push" ]]; then
echo "Not a push event; building all plugins."
echo "apply-filter=false" >> "$GITHUB_OUTPUT"
echo "changed-plugins=" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ -z "$BEFORE" || "$BEFORE" == "$zero_sha" ]] || ! git cat-file -e "$BEFORE" 2>/dev/null; then
echo "No usable base commit to diff against; building all plugins."
echo "apply-filter=false" >> "$GITHUB_OUTPUT"
echo "changed-plugins=" >> "$GITHUB_OUTPUT"
exit 0
fi
changed=$(git diff --name-only "$BEFORE" "$AFTER" -- plugins/ | sort -u)
echo "Changed plugin paths:"
echo "${changed:-<none>}"
echo "apply-filter=true" >> "$GITHUB_OUTPUT"
{
echo "changed-plugins<<EOF"
echo "$changed"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Discover submodules
id: discover-submodules
env:
APPLY_FILTER: ${{ steps.changed-plugins.outputs.apply-filter }}
CHANGED_PLUGINS: ${{ steps.changed-plugins.outputs.changed-plugins }}
run: |
sudo bash ./scripts/_gen_metadata.sh
sudo -E bash ./scripts/_submodules.sh > submodules.json
cat submodules.json
echo "submodule-matrix=$(cat submodules.json)" >> $GITHUB_OUTPUT
echo "has-submodules=$(jq '(.submodules | length) > 0' submodules.json)" >> $GITHUB_OUTPUT
- name: Commit Metadata
if: github.event_name != 'pull_request' && github.event.repository.fork == false
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add metadata.json
if git commit -m "chore: Add plugin metadata"; then
git push
else
echo "::debug::No changes to commit."
fi
make:
needs: prepare
if: needs.prepare.outputs.has-submodules == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare.outputs.submodule-matrix) }}
name: Build (${{ matrix.submodules.repository }})
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ matrix.submodules.repository }}
ref: ${{ matrix.submodules.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Set up SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add server to known hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Download Build Scripts
uses: actions/download-artifact@v4
with:
name: build-scripts
path: scripts/build/
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: |
pnpm install
env:
NODE_ENV: production
- name: Build Plugin
run: |
pnpm run build
env:
NODE_ENV: production
- name: Prepare Distribution Files
id: prepare-distribution
run: bash ./scripts/build/prepare-dist.sh --silent
- name: Upload to server
run: bash ./scripts/build/upload-dist.sh ${{ env.PLUGIN_NAME }}
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
- name: Upload Plugin Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PLUGIN_NAME }}
include-hidden-files: true
path: dist/