Skip to content

Commit

Permalink
chore: chunk plugins using repository_dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Mar 9, 2024
1 parent ef2254a commit 34cdff4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/chunk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---

on:
push:
branches:
- 'main'
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 '.chunks[$i]' chunks.json)
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 '{"event_type":"chunked_trigger","client_payload":$PAYLOAD}'
done
11 changes: 3 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: Publish semver tags to LuaRocks

on:
push:
branches:
- 'main'
schedule:
# Runs every 4 hours
- cron: "0 */4 * * *"
workflow_dispatch:
repository_dispatch:
types: [chunked_trigger]

jobs:
generate-matrix:
Expand All @@ -17,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "MATRIX=$(cat ./plugins.json | tr -d '\n\r')" >> $GITHUB_OUTPUT
run: echo "MATRIX=${{ github.event.client_payload }}" >> $GITHUB_OUTPUT
publish:
runs-on: ubuntu-latest
needs: generate-matrix
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chunks.json

0 comments on commit 34cdff4

Please sign in to comment.