-
Notifications
You must be signed in to change notification settings - Fork 6
34 lines (32 loc) · 1.13 KB
/
chunk.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
---
on:
push:
branches:
- 'main'
paths:
- 'plugins.json'
- .github/workflows/chunk.yml
- .github/workflows/publish.yml
- .github/workflows/publish-dev.yml
schedule:
# Runs every 4 hours
- cron: "0 */4 * * *"
workflow_dispatch:
jobs:
chunk-publish-workflows:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Trigger workflows for each chunk
run: |
jq '{plugins: .plugins | _nwise(256)}' plugins.json | jq -s '{chunks: .}' > chunks.json
# The above command outputs a nested list
CHUNK_COUNT=$(jq '.chunks | length' chunks.json)
for ((i = 0 ; i < CHUNK_COUNT ; i++ )); do
PAYLOAD=$(jq -c --argjson e "$i" '.chunks[$e]' chunks.json)
JSON_PAYLOAD=$(jq -nc --argjson data "$PAYLOAD" '{"event_type":"chunked_publish","client_payload":$data}')
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/nvim-neorocks/nurr/dispatches" \
-d "$JSON_PAYLOAD"
done