Skip to content

Commit

Permalink
Merge pull request #1 from PrefectHQ/first-implementation
Browse files Browse the repository at this point in the history
Initial implementation of workflow
  • Loading branch information
mitchnielsen authored Jan 31, 2025
2 parents bc52fb3 + 2d92d87 commit 93069ac
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@prefecthq/platform
25 changes: 25 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Static analysis

"on":
pull_request: {}

permissions: {}

jobs:
pre_commit_checks:
name: pre-commit checks
runs-on: ubuntu-latest
permissions:
# required to read from the repo
contents: read
steps:
- name: checkout
uses: actions/checkout@v4

- name: Install tool dependencies
uses: jdx/mise-action@v2

- name: Run pre-commit
run: |
pre-commit run --show-diff-on-failure --color=always --all-files
4 changes: 4 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tools]
pre-commit = '3.8.0'
shellcheck = '0.10.0'
yamllint = '1.35.1'
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
- id: detect-private-key
- id: no-commit-to-branch
- id: trailing-whitespace

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
args:
- --strict

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.7.2
hooks:
- id: shellcheck
args: ["--severity=error"]
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# actions-mise-upgrade
GitHub workflow to upgrade tools managed by mise

GitHub workflow to upgrade tools managed by [`mise`](https://mise.jdx.dev).

Uses the [`mise upgrade`](https://mise.jdx.dev/cli/upgrade.html) command to
check for the latest versions of each tool and update the `.mise.toml` with
the results.

## Inputs

There are currently no inputs to provide to this action.

## Usage

```yaml
name: Update mise tool versions
"on":
schedule:
- cron: 0 15 1 * * # First day of each month at 15:00 UTC
workflow_dispatch: {}

permissions: {}

jobs:
updatecli:
runs-on: ubuntu-latest
permissions:
# required to write to the repo
contents: write
# required to open a pr with changes
pull-requests: write
steps:
- name: upgrade mise tools
uses: prefecthq/actions-mise-upgrade@main
```
## References
- https://github.com/jdx/mise/discussions/1823: this issue discusses workflows for plugin updates. Might be worth following along in case there ends up being a more 'official' way to do this.
- https://github.com/jdx/mise/discussions/4057: this discussion mentions the `mise upgrade --bump` command we're using here, along with some context.
- https://github.com/jdx/mise/discussions/4241: this discussion suggests adding a changelog to the `self-update` command, which is somewhat related and hopefully will carry over to the `upgrade` command for us to use in pull request descriptions.
63 changes: 63 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
name: Update mise tool versions
author: PrefectHQ
description: This action will upgrade tools managed by mise and open a PR.

inputs: {}

runs:
using: composite
steps:
- name: checkout
uses: actions/checkout@v4
with:
# This should be 'main' anyway as it will run
# on a schedule, but let's be explicit so we can,
# for example, run this from pull request branches.
ref: 'main'

- name: install mise
uses: jdx/mise-action@v2

- name: upgrade tools in mise
run: mise upgrade --bump

- name: determine if there are changes
run: |
if [[ $(git diff --name-only | wc -l) -eq 0 ]]; then
echo "No changes detected, exiting"
echo "CHANGES=false" >> $GITHUB_ENV
exit 0
else
echo "CHANGES=true" >> $GITHUB_ENV
fi
- name: configure git
if: env.CHANGES == 'true'
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: determine branch name
if: env.CHANGES == 'true'
run: |
echo "BRANCH_NAME=mise-updates-$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: commit and push changes
if: env.CHANGES == 'true'
run: |
git checkout -b $BRANCH_NAME
git add .mise.toml
git commit -m 'Update mise tool versions'
git push --set-upstream origin $BRANCH_NAME
- name: create pull request
if: env.CHANGES == 'true'
run: |
gh pr create \
--base main \
--title "Update mise tool versions" \
--label automated-dependency-updates
env:
# Required for the `gh` CLI
GH_TOKEN: ${{ github.token }}

0 comments on commit 93069ac

Please sign in to comment.