[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"C3oql7ZyGN":3},"# Lean Update\n\nA GitHub Action that attempts to update Lean and dependencies of a Lean project. This is basically a fork of [oliver-butterley/lean-update](https://github.com/oliver-butterley/lean-update) but more feature-rich.\n\n## Quick Setup\n\nCreate a file named `update.yml` in the `.github/workflows` directory.\n\n### If you want to keep dependencies always up-to-date\n\nTo keep dependencies always up-to-date, you might want to configure as follows:\n\n```yml\nname: Update Lean Project\n\non:\n  schedule:\n    - cron: \"0 0 * * *\" # every day\n  workflow_dispatch: # allows workflow to be triggered manually\n\njobs:\n  update_lean:\n    # this is needed for private repositories\n    permissions:\n      contents: write\n      pull-requests: write\n      issues: write\n\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v6\n\n      - name: Update Lean project\n        uses: leanprover-community/lean-update@main\n```\n\n### When you only want to update when there is a new Lean version\n\nIf you want to skip updates unless there is a change to the `lean-toolchain` file, you might want to configure as follows:\n\n```yml\nname: Update Lean Project\n\non:\n  schedule:\n    - cron: \"0 0 * * *\" # every day\n  workflow_dispatch: # allows workflow to be triggered manually\n\njobs:\n  update_lean:\n    # this is needed for private repositories\n    permissions:\n      contents: write\n      pull-requests: write\n      issues: write\n\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v6\n      - name: Update Lean project\n        uses: leanprover-community/lean-update@main\n        with:\n          update_if_modified: lean-toolchain\n```\n\n### If you want to receive notifications on Zulip when the update fails\n\n1. 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\".\n2. Next, register the bot's API key as a secret named `ZULIP_API_KEY` in your repository. You can set up secrets from the repository's \"Settings\".\n3. Prepare a workflow file like the following:\n\n```yml\nname: Update Lean Project\n\non:\n  schedule:\n    - cron: \"0 0 * * *\" # every day\n  workflow_dispatch: # allows workflow to be triggered manually\n\njobs:\n  update_lean:\n    # this is needed for private repositories\n    permissions:\n      contents: write\n      pull-requests: write\n      issues: write\n\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v6\n\n      - name: Update Lean project\n        id: lean-update\n        uses: leanprover-community/lean-update@main\n        with:\n          on_update_fails: \"silent\"\n\n      - name: Notification\n        if: steps.lean-update.outputs.result == 'update-fail'  # only send a message when the update fails\n        uses: zulip/github-actions-zulip/send-message@v1\n        with:\n          api-key: ${{ secrets.ZULIP_API_KEY }} # Zulip API key of your bot\n          email: \"***-bot@leanprover.zulipchat.com\" # your Zulip bot's email\n          organization-url: 'https://leanprover.zulipchat.com'\n          to: \"123456\" # user_id\n          type: \"private\" # private message\n          content: |\n             ❌ The update of ${{ github.repository }} has failed\n\n             - [See Action Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n             - [See Commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n```\n\n## Description of Functionality\n\n1. This Action first installs [elan](https://github.com/leanprover/elan) and runs `lake update`. This fetches the latest Lean release and updates all dependent packages to their latest versions.\n\n2. If `lake update` determines that all dependencies are already up to date, this Action does nothing further.\n\n3. Subsequently, this GitHub Action validates the updated code. This performs the build process, runs tests if a test driver is configured, and executes lint checks if a lint driver is set up. You can configure what build arguments are passed to `lake build` using the `build_args` option.\n\n4. This Action classifies the post-update validation results into two categories: success or failure.\n    1. If successful, it behaves according to the setting specified in the `on_update_succeeds` option. By default, this is set to `pr`, which submits the updated code as a pull request. However, if the `update_if_modified` option is set to `lean-toolchain`, the Action does nothing unless the Lean version has been updated.\n    2. If it fails, it behaves according to the setting specified in the `on_update_fails` option. By default, this is set to `issue`, which submits an issue indicating that the update failed.\n\n## Details of Option\n\nSee [action.yml](./action.yml) for details.\n",1791060108608]