From 6641a61c792b2bcff76f25ef4115314badae90e9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 27 May 2021 09:00:44 -0500 Subject: [PATCH] Add workflow to build folder images for examples .. this will not work until https://github.com/circuitpython/CircuitPython_Library_Screenshot_Maker/pull/5 is merged. --- .github/workflows/images.yml | 51 ++++++++++++++++++++++++++++++++++++ .gitignore | 4 +++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/images.yml diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml new file mode 100644 index 00000000..38f26c78 --- /dev/null +++ b/.github/workflows/images.yml @@ -0,0 +1,51 @@ +name: Generate folder images + +on: + schedule: + - cron: '0 10 * * *' + workflow_dispatch: + push: + branches: [master] + +concurrency: + group: folder-images + cancel-in-progress: true + +jobs: + update-images: + runs-on: ubuntu-20.04 + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + + - uses: actions/checkout@v2.2.0 + + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Checkout screenshot maker + run: git clone --depth=1 https://github.com/circuitpython/CircuitPython_Library_Screenshot_Maker + + - name: Install dependencies + run: pip install -r CircuitPython_Library_Screenshot_Maker/requirements.txt + + - name: Generate images + run: | + find libraries -pattern "libraries/*/examples/*.py" -exec python3 CircuitPython_Library_Screenshot_Maker/create_requirement_images_bundle.py {} + + + - name: Commit updates + run: | + cd generated_images + git config --global user.name "${GITHUB_ACTOR} (github actions cron)" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config --global init.defaultBranch main + git init + for i in *.png; do echo "$i
"; done > index.html + git add *.png index.html + git remote add origin https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + if git commit -m"update images"; then git push -f origin HEAD:folder-images; fi + diff --git a/.gitignore b/.gitignore index e72d2e35..02334ad3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,8 @@ build/* *zip .env bundles +CircuitPython_Library_Screenshot_Maker/ .DS_Store +generated_images/ +latest_bundle_data.json +latest_bundle_tag.json