Skip to content

Commit

Permalink
Move maintainance workflows to own repo
Browse files Browse the repository at this point in the history
  • Loading branch information
urob committed Dec 10, 2024
1 parent 3fdd19a commit 7e10210
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 183 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Create a new module release
on:
pull_request:
types:
- closed
branches:
- main

jobs:
build:
permissions:
contents: write
uses: urob/zmk-modules-actions/.github/workflows/upgrade-module.yml@main
118 changes: 0 additions & 118 deletions .github/workflows/run-module-tests.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Run tests

on:
workflow_dispatch:
Expand All @@ -17,4 +17,4 @@ on:

jobs:
build:
uses: urob/zmk-leader-key/.github/workflows/run-module-tests.yml@main
uses: urob/zmk-modules-actions/.github/workflows/run-tests.yml@main
68 changes: 5 additions & 63 deletions .github/workflows/upgrade-zmk.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,13 @@
name: Upgrade to latest ZMK version
name: Check for new ZMK releases

on:
workflow_dispatch:
schedule:
# Runs every day at 22:00 UTC (17:00 ET)
- cron: "0 22 * * *"

env:
upstream: zmkfirmware/zmk
west_path: tests/west.yml
upgrade_branch: upgrade-zmk
upgrade-label: "upgrade-version"
- cron: "0 22 * * *" # Run daily at 22:00 UTC (17:00 ET)

jobs:
upgrade-zmk:
name: Upgrade ZMK & open PR
runs-on: ubuntu-latest
build:
uses: urob/zmk-modules-actions/.github/workflows/upgrade-zmk.yml@main
permissions:
contents: write
pull-requests: write
actions: write
steps:
- name: Checkout main branch
uses: actions/checkout@v4

- name: Get latest ZMK version
id: get-zmk-version
run: |
ZMK_VERSION=$(curl -s https://api.github.com/repos/${{ env.upstream }}/releases/latest | jq -r '.tag_name')
echo "ZMK_VERSION=${ZMK_VERSION%.*}" >> $GITHUB_ENV
echo "ZMK_VERSION: ${ZMK_VERSION%.*}"
- name: Upgrade ZMK version
run: |
export ver=${{ env.ZMK_VERSION }}
yq e -i '(.manifest.projects[] | select(.name=="zmk") | .revision) = env(ver)' ${{ env.west_path }}
cat ${{ env.west_path }}
- name: Detect changes
id: changes
run:
# This output boolean tells us if the dependencies have actually changed
echo "count=$(git status --porcelain=v1 2>/dev/null | wc -l)" >> $GITHUB_OUTPUT

- name: Commit & push changes
# Only push if changes exist
if: steps.changes.outputs.count > 0
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git commit -a -m "Upgrade ZMK to ${{ env.ZMK_VERSION }}"
git push -f origin ${{ github.ref_name }}:${{ env.upgrade_branch }}
- name: Open pull request if needed
if: steps.changes.outputs.count > 0
run: |
# Personal access token requires: Repo read access to metadata, read & write acess to actions and pull requests
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
echo "${{ secrets.ACTIONS_UPGRADE_ZMK }}" | gh auth login --with-token
# Only open a PR if the branch is not attached to an existing one
PR=$(gh pr list --head ${{ env.upgrade_branch }} --json number -q '.[0].number')
if [ -z $PR ]; then
gh pr create \
--head ${{ env.upgrade_branch }} \
--title "Upgrade ZMK to ${{ env.ZMK_VERSION }}" \
--label "${{ env.upgrade-label }}" \
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
else
echo "Pull request already exists, won't create a new one."
fi
secrets: inherit

0 comments on commit 7e10210

Please sign in to comment.