Skip to content

Commit

Permalink
Adapt workflow to action
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchnielsen committed Jan 29, 2025
1 parent bf17dc6 commit 2d92d87
Showing 1 changed file with 61 additions and 70 deletions.
131 changes: 61 additions & 70 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,72 +1,63 @@
---
name: Update mise tool versions

"on":
schedule:
- cron: 0 15 1 * * # First of the month @ 3pm UTC
workflow_dispatch: {}

permissions: {}

jobs:
updatecli_major:
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: 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 }}
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 2d92d87

Please sign in to comment.