A GitHub Action that attempts to update Lean and dependencies of a Lean project. This is basically a fork of oliver-butterley/lean-update but more feature-rich.
Create a file named update.yml in the .github/workflows directory.
To keep dependencies always up-to-date, you might want to configure as follows:
name: Update Lean Project
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch: # allows workflow to be triggered manually
jobs:
update_lean:
# this is needed for private repositories
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Update Lean project
uses: leanprover-community/lean-update@mainIf you want to skip updates unless there is a change to the lean-toolchain file, you might want to configure as follows:
name: Update Lean Project
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch: # allows workflow to be triggered manually
jobs:
update_lean:
# this is needed for private repositories
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Update Lean project
uses: leanprover-community/lean-update@main
with:
update_if_modified: lean-toolchain- First, create a bot in Zulip and note its API key. Be careful not to create a new account - Zulip has a dedicated feature for "creating a bot".
- Next, register the bot's API key as a secret named
ZULIP_API_KEYin your repository. You can set up secrets from the repository's "Settings". - Prepare a workflow file like the following:
name: Update Lean Project
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch: # allows workflow to be triggered manually
jobs:
update_lean:
# this is needed for private repositories
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Update Lean project
id: lean-update
uses: leanprover-community/lean-update@main
with:
on_update_fails: "silent"
- name: Notification
if: steps.lean-update.outputs.result == 'update-fail' # only send a message when the update fails
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_API_KEY }} # Zulip API key of your bot
email: "***[email protected]" # your Zulip bot's email
organization-url: 'https://leanprover.zulipchat.com'
to: "123456" # user_id
type: "private" # private message
content: |
❌ The update of ${{ github.repository }} has failed
- [See Action Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- [See Commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }})-
This Action first installs elan and runs
lake update. This fetches any new Lean prereleases or releases and updates all dependent packages to their latest versions. -
If
lake updatedetermines that all dependencies are already up to date, this Action does nothing further. -
Subsequently, this GitHub Action calls another GitHub Action called lean-action to check if the updated code works correctly. This performs the build process, runs tests if a test driver is configured, and executes lint checks if a lint driver is set up. Whether to perform tests or lint checks is automatically determined by lean-action. However, you can configure what build arguments are passed to
lake buildwhen lean-action is executed using thebuild_argsoption. -
This Action classifies the results of lean-action into two categories: success or failure.
- If successful, it behaves according to the setting specified in the
on_update_succeedsoption. By default, this is set topr, which submits the updated code as a pull request. However, if theupdate_if_modifiedoption is set tolean-toolchain, the Action does nothing unless the Lean version has been updated. - If it fails, it behaves according to the setting specified in the
on_update_failsoption. By default, this is set toissue, which submits an issue indicating that the update failed.
- If successful, it behaves according to the setting specified in the
See action.yml for details.