Skip to content

Commit 32ebc93

Browse files
authored
Merge pull request #315 from adafruit/library-example-drive-pictures
Add workflow to build folder images for examples
2 parents f6cb2b9 + 6641a61 commit 32ebc93

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/images.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Generate folder images
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * *'
6+
workflow_dispatch:
7+
push:
8+
branches: [master]
9+
10+
concurrency:
11+
group: folder-images
12+
cancel-in-progress: true
13+
14+
jobs:
15+
update-images:
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- name: Dump GitHub context
19+
env:
20+
GITHUB_CONTEXT: ${{ toJson(github) }}
21+
run: echo "$GITHUB_CONTEXT"
22+
23+
- uses: actions/[email protected]
24+
25+
- name: Set up Python 3.9
26+
uses: actions/setup-python@v1
27+
with:
28+
python-version: 3.9
29+
30+
- name: Checkout screenshot maker
31+
run: git clone --depth=1 https://github.com/circuitpython/CircuitPython_Library_Screenshot_Maker
32+
33+
- name: Install dependencies
34+
run: pip install -r CircuitPython_Library_Screenshot_Maker/requirements.txt
35+
36+
- name: Generate images
37+
run: |
38+
find libraries -pattern "libraries/*/examples/*.py" -exec python3 CircuitPython_Library_Screenshot_Maker/create_requirement_images_bundle.py {} +
39+
40+
- name: Commit updates
41+
run: |
42+
cd generated_images
43+
git config --global user.name "${GITHUB_ACTOR} (github actions cron)"
44+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
45+
git config --global init.defaultBranch main
46+
git init
47+
for i in *.png; do echo "<a href=\"$i\">$i</a><br>"; done > index.html
48+
git add *.png index.html
49+
git remote add origin https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
50+
if git commit -m"update images"; then git push -f origin HEAD:folder-images; fi
51+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ build/*
22
*zip
33
.env
44
bundles
5+
CircuitPython_Library_Screenshot_Maker/
56
.DS_Store
7+
generated_images/
8+
latest_bundle_data.json
9+
latest_bundle_tag.json

0 commit comments

Comments
 (0)