-
Notifications
You must be signed in to change notification settings - Fork 3
146 lines (116 loc) · 4.9 KB
/
ci.yml
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
name: CI
on:
- push
- pull_request
- workflow_dispatch
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
submodule-matrix: ${{ steps.discover-submodules.outputs.submodule-matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
persist-credentials: true
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install pnpm
run: npm install -g pnpm
- name: Discover submodules
id: discover-submodules
run: |
sudo node ./scripts/discover-submodules.js > submodules.json
echo "Original Submodule JSON content:"
cat submodules.json
# Transform JSON into a list of 'owner/repo' strings
jq -c '[.[] | "\(.owner)/\(.repo)"]' submodules.json > transformed-submodules.json
echo "Transformed Submodule JSON content:"
cat transformed-submodules.json
# Set the output for the submodule matrix
echo "submodule-matrix=$(cat transformed-submodules.json)" >> $GITHUB_OUTPUT
make:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repository: ${{ fromJson(needs.prepare.outputs.submodule-matrix) }}
steps:
- name: Checkout specific submodule repository
uses: actions/checkout@v2
with:
repository: ${{ matrix.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install Google Cloud SDK
run: |
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get update && sudo apt-get install google-cloud-cli
- name: Authenticate to Google Cloud
env:
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
run: |
echo "${GCP_SERVICE_ACCOUNT_KEY}" > gcloud-key.json
gcloud auth activate-service-account --key-file=gcloud-key.json
gcloud config set project steam-brew
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies and build plugin
run: |
ls -R
pnpm install
pnpm run build
env:
NODE_ENV: production
- name: Copy files to dist
id: copy-files-to-dist
run: |
mkdir -p dist
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; }
cp "requirements.txt" dist/requirements.txt 2>/dev/null || echo "::warning::requirements.txt not found, skipping."
cp "README.md" dist/README.md 2>/dev/null || echo "::warning::README.md not found, skipping."
cp "README" dist/README 2>/dev/null || echo "::warning::README not found, skipping."
BACKEND_DIR=$(jq -r '.backend' plugin.json)
if [ "$BACKEND_DIR" != "null" ]; then
cp -r "$BACKEND_DIR" ./dist/"$BACKEND_DIR"
else
cp -r "backend" ./dist/backend 2>/dev/null || echo "::warning::backend directory not found, skipping."
fi
FRONTEND_DIR=$(jq -r '.frontend' plugin.json)
if [ "$FRONTEND_DIR" != "null" ]; then
cp -r "$FRONTEND_DIR" ./dist/"$FRONTEND_DIR"
else
cp -r "frontend" ./dist/frontend 2>/dev/null || echo "::warning::frontend directory not found, skipping."
fi
include=$(jq -r '.include // [] | .[]' plugin.json)
if [ -z "$include" ]; then
echo "::notice::No additional files to include."
else
echo "::notice::Including additional files: $include"
for item in $include; do
cp -r "./$item" "./dist/$item"
done
fi
echo "::notice::Computing plugin metadata..."
echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/metadata.json
id=$(jq -r '.id' dist/metadata.json)
echo "id=$id" >> $GITHUB_OUTPUT
cd dist
echo "::notice::Building plugin archive..."
zip -r "$id.zip" .
echo "::notice::Successfully built plugin."
echo "::notice::Uploading plugin to database..."
gsutil cp "$id.zip" gs://millennium-d9ce0.appspot.com/plugins/"$id.zip"
echo "::notice::Successfully uploaded plugin to database."