Skip to content

Commit 1a276c0

Browse files
committed
add workflow that trigger libraries rebuild when package_adafruit_index.json is changed on gh-pages branch
1 parent 09272e1 commit 1a276c0

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Trigger Libraries
2+
3+
on:
4+
push:
5+
branches: gh-pages
6+
paths: 'package_adafruit_index.json'
7+
8+
jobs:
9+
trigger-libraries:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Setup Python
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: '3.x'
16+
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Trigger Script
21+
env:
22+
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
23+
run: python3 examples/trigger_libraries.py
24+

examples/trigger_libraries.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import shutil
3+
import sys
4+
import subprocess
5+
import time
6+
7+
all_libs = [
8+
'Adafruit_TinyUSB_Arduino',
9+
'Adafruit_SPIFlash',
10+
]
11+
12+
GH_REPO_TOKEN = os.environ["GH_REPO_TOKEN"]
13+
14+
gh_request = 'curl -X POST -H "Authorization: token {}"'.format(GH_REPO_TOKEN) + \
15+
' -H "Accept: application/vnd.github.everest-preview+json"' + \
16+
' -H "Content-Type: application/json"' + \
17+
' --data \'{"event_type": "rebuild"}\' '
18+
19+
url = 'https://api.github.com/repos/adafruit/{}/dispatches'
20+
21+
for lib in all_libs:
22+
subprocess.run(gh_request + url.format(lib), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

0 commit comments

Comments
 (0)