Skip to content

keymap

keymap #21

Workflow file for this run

name: keymap
on:
# Needs push so it runs for tags to generate a release
push:
tags:
- "v*.*.*"
paths:
- ".images/config.yml"
- ".images/info.json"
- ".github/workflows/keymap.yml"
workflow_run:
workflows: ["Build RMK firmware"]
types:
- completed
workflow_dispatch:
jobs:
draw-keymaps:
runs-on: ubuntu-slim
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ github.head_ref }}
- uses: astral-sh/setup-uv@v3
- run: | # use https://nickcoutsos.github.io/keymap-layout-tools/ to generate info.json
uvx --from git+https://github.com/willpuckett/keymap-drawer keymap \
-c .images/config.yml parse -r rmk/keyboard.toml | \
uvx --from git+https://github.com/willpuckett/keymap-drawer keymap \
draw -j .images/info.json - > .images/keymap.svg
- uses: actions/upload-artifact@v4
with:
name: keymaps
path: ".images/keymap.svg"
include-hidden-files: true
push-or-release:
runs-on: ubuntu-latest
needs: draw-keymaps
permissions:
contents: write # allow workflow to commit to the repository and create releases
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ github.head_ref }}
- uses: actions/download-artifact@v4
with:
name: keymaps
path: ".images"
- name: get commit info
id: last_commit
run: |
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
echo "author=$(git log -1 --pretty='%an <%ae>')" >> $GITHUB_OUTPUT
git config pull.rebase true
git pull || true
- uses: stefanzweifel/git-auto-commit-action@v5
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
file_pattern: ".images/keymap.svg"
# So the previous commit is amended instead of creating a new one when desired
# 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
commit_author: ${{ steps.last_commit.outputs.author }}
commit_message: "${{ steps.last_commit.outputs.message }}"
commit_options: "--amend --no-edit"
push_options: "--force-with-lease"
skip_fetch: true
- name: Release
uses: softprops/action-gh-release@v2
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
files: ".images/keymap.svg"
draft: false
prerelease: false
fail_on_unmatched_files: true