Skip to content

Draw keymaps

Draw keymaps #16

Workflow file for this run

name: Draw keymaps
on:
workflow_dispatch: # can be triggered manually
push: # automatically run on changes to following paths
paths:
- "config/*.keymap"
- "config/keymap_drawer.yaml"
env:
km_dr_version: main
km_dr_config: config/keymap_drawer.yaml
keymap: config/glove80.keymap
output_folder: keymap-drawer
jobs:
parse:
runs-on: ubuntu-latest
steps:
- name: Install keymap-drawer (git) # TODO use actions/setup-python to cacne deps
run: python3 -m pip install "git+https://github.com/caksoylar/keymap-drawer.git@${{ env.km_dr_version }}"
- name: Checkout
uses: actions/checkout@v3
# TODO get keyboads & configs dynamically
- name: Parse
run: |
KEYMAP="${{ env.keymap }}"
CONFIG="${{ env.km_dr_config }}"
keymap -c "$CONFIG" parse -z "$KEYMAP" > keymap.yaml
- name: Upload config
uses: actions/upload-artifact@v3
with:
name: config.yaml
path: ${{ env.km_dr_config }}
- name: Upload keymap yaml
uses: actions/upload-artifact@v3
with:
name: glove80.yaml
path: keymap.yaml
scan-layers:
runs-on: ubuntu-latest
needs:
- parse
steps:
- name: Download keymap yaml
uses: actions/download-artifact@v3
with:
name: glove80.yaml
- name: Checkout
uses: actions/checkout@v3
- name: Install PyYaml
run: python3 -m pip install pyyaml
- name: Scan layers
id: scan
run: |
set -o pipefail
python3 .github/workflows/layers.py glove80.yaml \
| sed "s/^/layers=/g" >> $GITHUB_OUTPUT
outputs:
layers: ${{ steps.scan.outputs.layers }}
draw-all-layers:
runs-on: ubuntu-latest
needs:
- parse
steps:
- name: Download config
uses: actions/download-artifact@v3
with:
name: config.yaml
- name: Download keymap yaml
uses: actions/download-artifact@v3
with:
name: glove80.yaml
- name: Install keymap-drawer (git)
run: python3 -m pip install "git+https://github.com/caksoylar/keymap-drawer.git@${{ env.km_dr_version }}"
- name: Draw keymap
run: keymap -c config.yaml draw glove80.yaml > keymap.svg
- name: Upload keymap svg
uses: actions/upload-artifact@v3
with:
name: glove80.svg
path: keymap.svg
draw-each-layer:
runs-on: ubuntu-latest
strategy:
matrix:
layer: ${{ needs.scan-layers.outputs.layers }}
needs:
- parse
- scan-layers
steps:
- name: Download config
uses: actions/download-artifact@v3
with:
name: config.yaml
- name: Download keymap yaml
uses: actions/download-artifact@v3
with:
name: glove80.yaml
- name: Install keymap-drawer (git)
run: python3 -m pip install "git+https://github.com/caksoylar/keymap-drawer.git@${{ env.km_dr_version }}"
- name: Draw layer keymap
run: keymap -c config.yaml draw glove80.yaml -s "${{ matrix.layer }}" > keymap.svg
- name: Upload layer keymap svg
uses: actions/upload-artifact@v3
with:
name: glove80_${{ matrix.layer }}.svg
path: keymap.svg
commit:
runs-on: ubuntu-latest
needs:
- draw-all-layers
- draw-each-layer
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# So the reference to the parent commit is available when amending
# See:
# - https://github.com/stefanzweifel/git-auto-commit-action#using---amend-and---no-edit-as-commit-options
# - https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950
# - https://github.com/actions/checkout
fetch-depth: ${{ (inputs.amend_commit == true && 2) || 1 }}
submodules: recursive
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: ${{ env.output_folder }}
- name: Print # TODO actually commet changes...
run: |
echo "Output Folder is ${{ env.output_folder }}"
echo "Found the folloing files:"
ls "${{ env.output_folder }}"
git status