Skip to content

Draw keymaps

Draw keymaps #20

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
keyboard: glove80
output_folder: keymap-drawer
jobs:
draw:
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: Install PyYaml
run: python3 -m pip install pyyaml
- 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
# TODO get keyboads & configs dynamically
- name: Parse
run: |
# TODO set generic vars in one place globally
KEYBOARD="${{ env.keyboard }}"
KEYMAP="config/${KEYBOARD}.keymap"
CONFIG="${{ env.km_dr_config }}"
OUTPUT="${{ env.output_folder }}/${KEYBOARD}.yaml"
keymap -c "$CONFIG" parse -z "$KEYMAP" > "$OUTPUT"
- name: Draw keymap
run: |
KEYBOARD="${{ env.keyboard }}"
KEYMAP="config/${KEYBOARD}.keymap"
CONFIG="${{ env.km_dr_config }}"
OUTPUT="${{ env.output_folder }}/${KEYBOARD}.svg"
keymap -c "$CONFIG" draw "$KEYMAP" > "$OUTPUT"
- name: Draw layer keymap
run: |
# Ensure errors propagate when piping stdout
set -o pipefail
KEYBOARD="${{ env.keyboard }}"
KEYMAP="config/${KEYBOARD}.keymap"
CONFIG="${{ env.km_dr_config }}"
# Function to draw the given layer's keymap
draw() {
LAYER="$1"
OUTPUT="${{ env.output_folder }}/${KEYBOARD}_${LAYER}.yaml"
keymap -c "$CONFIG" draw "$KEYMAP" -s "$LAYER" > "$OUTPUT"
}
# Run `draw()` for each layer in the keymap. Up to 4 layers at a time...
python3 .github/workflows/layers.py "$KEYMAP" \
| parallel --jobs 4 draw
- 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