├── .czrc ├── .envrc ├── .gitattributes ├── .github ├── renovate.json └── workflows │ ├── auto-rebase.yml │ └── ci.yml ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── .releaserc.json ├── .rgignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── action.yml ├── flake.lock └── flake.nix /.czrc: -------------------------------------------------------------------------------- 1 | { 2 | "path": "cz-conventional-changelog" 3 | } 4 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use flake 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | flake.lock linguist-generated=true 2 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base", ":enablePreCommit"], 3 | "semanticCommits": "enabled", 4 | "lockFileMaintenance": { "enabled": false }, 5 | "enabledManagers": ["github-actions"], 6 | "automerge": true, 7 | "labels": ["dependencies"] 8 | } 9 | -------------------------------------------------------------------------------- /.github/workflows/auto-rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | on: 3 | push: 4 | branches-ignore: 5 | # Ignore branches automatically created by github-rebase 6 | - rebase-pull-request** 7 | - cherry-pick-rebase-pull-request** 8 | pull_request: 9 | types: 10 | - labeled 11 | 12 | jobs: 13 | auto-rebase: 14 | name: AutoRebase 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/create-github-app-token@v2 18 | id: generate_token 19 | with: 20 | app-id: ${{ secrets.APP_ID }} 21 | private-key: ${{ secrets.APP_PRIVATE_KEY }} 22 | 23 | - uses: Label305/AutoRebase@v0.1 24 | with: 25 | github_token: ${{ steps.generate_token.outputs.token }} 26 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | workflow_dispatch: 10 | schedule: 11 | - cron: "0 */6 * * *" 12 | 13 | concurrency: 14 | group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | get-flakes: 19 | runs-on: ubuntu-latest 20 | outputs: 21 | matrix: ${{ steps.get-flakes.outputs.matrix }} 22 | steps: 23 | - uses: actions/checkout@v4 24 | - uses: cachix/install-nix-action@v26 25 | with: 26 | install_url: https://releases.nixos.org/nix/nix-2.18.1/install 27 | extra_nix_config: | 28 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 29 | - name: generate flake matrix 30 | id: get-flakes 31 | run: | 32 | set -euo pipefail 33 | 34 | flakes="$(nix flake metadata --json | jq -rcM '.locks.nodes.root.inputs | {flake: keys}')" 35 | echo "matrix=$flakes" >> "$GITHUB_OUTPUT" 36 | flake-update: 37 | runs-on: ubuntu-latest 38 | needs: 39 | - get-flakes 40 | strategy: 41 | fail-fast: false 42 | matrix: ${{ fromJson(needs.get-flakes.outputs.matrix) }} 43 | steps: 44 | - name: Checkout 45 | uses: actions/checkout@v4 46 | 47 | - name: Install Nix 48 | uses: cachix/install-nix-action@v26 49 | with: 50 | nix_path: nixpkgs=channel:nixos-unstable-small 51 | install_url: https://releases.nixos.org/nix/nix-2.18.1/install 52 | extra_nix_config: | 53 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 54 | 55 | - uses: actions/create-github-app-token@v1.9.1 56 | id: generate-token 57 | with: 58 | app-id: ${{ secrets.APP_ID }} 59 | private-key: ${{ secrets.APP_PRIVATE_KEY }} 60 | 61 | - name: Update ${{ matrix.flake }} 62 | uses: ./ 63 | with: 64 | dependency: ${{ matrix.flake }} 65 | github-token: ${{ secrets.GITHUB_TOKEN }} 66 | pull-request-token: ${{ steps.generate-token.outputs.token }} 67 | pull-request-author: "phillip-ground[bot] " 68 | pull-request-labels: dependencies,autorebase:opt-in 69 | automerge: true 70 | delete-branch: true 71 | release: 72 | runs-on: ubuntu-latest 73 | concurrency: release 74 | needs: 75 | - flake-update 76 | steps: 77 | - name: Generate a GitHub token 78 | uses: actions/create-github-app-token@v1.9.1 79 | id: generate-token 80 | with: 81 | app-id: ${{ secrets.APP_ID }} 82 | private-key: ${{ secrets.APP_PRIVATE_KEY }} 83 | 84 | - name: checkout 85 | uses: actions/checkout@v4 86 | with: 87 | fetch-depth: 0 88 | token: ${{ steps.generate-token.outputs.token }} 89 | 90 | - name: setup nodejs 91 | uses: actions/setup-node@v4 92 | with: 93 | node-version: 20 94 | 95 | - uses: cycjimmy/semantic-release-action@v4.1.0 96 | with: 97 | extra_plugins: | 98 | @semantic-release/commit-analyzer 99 | @semantic-release/release-notes-generator 100 | @semantic-release/changelog 101 | @semantic-release/github 102 | @semantic-release/git 103 | env: 104 | GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} 105 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directory 2 | node_modules 3 | 4 | # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | jspm_packages/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | .env.test 71 | 72 | # parcel-bundler cache (https://parceljs.org/) 73 | .cache 74 | 75 | # next.js build output 76 | .next 77 | 78 | # nuxt.js build output 79 | .nuxt 80 | 81 | # vuepress build output 82 | .vuepress/dist 83 | 84 | # Serverless directories 85 | .serverless/ 86 | 87 | # FuseBox cache 88 | .fusebox/ 89 | 90 | # DynamoDB Local files 91 | .dynamodb/ 92 | 93 | # OS metadata 94 | .DS_Store 95 | Thumbs.db 96 | 97 | # Ignore built ts files 98 | __tests__/runner/* 99 | lib/**/* 100 | .direnv 101 | .pre-commit-config.yaml 102 | result 103 | result-* 104 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | .pre-commit-config.yaml 5 | CHANGELOG.md 6 | .direnv 7 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "semi": true, 4 | "singleQuote": false, 5 | "arrowParens": "avoid", 6 | "useTabs": false 7 | } 8 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "branches": ["main"], 3 | "plugins": [ 4 | "@semantic-release/commit-analyzer", 5 | "@semantic-release/release-notes-generator", 6 | ["@semantic-release/changelog", { "changelogTitle": "# Release Notes" }], 7 | ["@semantic-release/github", { "successComment": false }], 8 | ["@semantic-release/git", { "assets": ["CHANGELOG.md"] }] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.rgignore: -------------------------------------------------------------------------------- 1 | !.github 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## [2.0.1](https://github.com/cpcloud/flake-update-action/compare/v2.0.0...v2.0.1) (2023-12-17) 4 | 5 | 6 | ### Reverts 7 | 8 | * fix(action): use non deprecated version of `nix flake update` ([9462931](https://github.com/cpcloud/flake-update-action/commit/9462931effdd11d9280bcdf7314a923ee5165a35)) 9 | 10 | # [2.0.0](https://github.com/cpcloud/flake-update-action/compare/v1.0.4...v2.0.0) (2023-12-09) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * **action:** use non deprecated version of `nix flake update` ([fc385f8](https://github.com/cpcloud/flake-update-action/commit/fc385f84129b38dc0ced7f1a5d2d9302cc04e639)) 16 | 17 | 18 | ### BREAKING CHANGES 19 | 20 | * **action:** `nix flake update ` is now used, which requires a newer version of nix. 21 | 22 | ## [1.0.4](https://github.com/cpcloud/flake-update-action/compare/v1.0.3...v1.0.4) (2022-12-30) 23 | 24 | 25 | ### Bug Fixes 26 | 27 | * use `GITHUB_OUTPUT` ([0f713ae](https://github.com/cpcloud/flake-update-action/commit/0f713ae705dad03e8bd2427fb807a6673a131321)) 28 | 29 | ## [1.0.3](https://github.com/cpcloud/flake-update-action/compare/v1.0.2...v1.0.3) (2022-12-30) 30 | 31 | 32 | ### Bug Fixes 33 | 34 | * **deps:** bump to latest version of `flake-dep-info-action` ([c26fee3](https://github.com/cpcloud/flake-update-action/commit/c26fee3dc798eb2404517dfee2f7f30c7f434600)) 35 | * **deps:** update compare-commits action ([2ceb1ea](https://github.com/cpcloud/flake-update-action/commit/2ceb1ea980e8bbc054e6d52b8ad311acda44e5a6)) 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2021 Phillip Cloud 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Update flake dependencies 2 | 3 | This action will create PRs that update flake dependencies. 4 | 5 | ## Usage in a GitHub workflow 6 | 7 | ```yaml 8 | jobs: 9 | update-deps: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | dependency: 15 | - nixpkgs 16 | - poetry2nix 17 | steps: 18 | - name: Update ${{ matrix.dependency }} 19 | uses: cpcloud/flake-update-action@* 20 | with: 21 | dependency: ${{ matrix.dependency }} 22 | pull-request-token: ${{ secrets.ANOTHER_TOKEN }} 23 | pull-request-author: "Me " 24 | github-token: ${{ secrets.GITHUB_TOKEN }} 25 | ``` 26 | 27 | ## Inputs 28 | 29 | ```yaml 30 | inputs: 31 | dependency: 32 | required: true 33 | description: "The flake dependency to update" 34 | pull-request-token: 35 | required: true 36 | description: "Access token used to create pull requests" 37 | pull-request-author: 38 | required: true 39 | description: "The author of the pull request" 40 | pull-request-merge-method: 41 | required: false 42 | description: "The merge method for automerging pull requests" 43 | default: "rebase" 44 | delete-branch: 45 | required: false 46 | default: "false" 47 | description: "Delete branch upon merge" 48 | github-token: 49 | required: false 50 | description: "Access token to increase the rate limit for GitHub API requests" 51 | pull-request-branch-prefix: 52 | required: false 53 | default: "create-pull-request/update-" 54 | description: "Prefix of the branch for the pull request" 55 | pull-request-labels: 56 | required: false 57 | description: "Labels to attach to the pull request" 58 | default: "" 59 | include-merge-commits: 60 | required: false 61 | description: "Whether to show merge commits in the log" 62 | default: "false" 63 | automerge: 64 | required: false 65 | description: "Whether to set the pull request to automatically merge on success. Requires that the automerge feature is enabled on GitHub." 66 | default: "false" 67 | ``` 68 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "flake-update-action" 2 | description: "Update flake dependencies" 3 | author: "Phillip Cloud" 4 | inputs: 5 | dependency: 6 | required: true 7 | description: "The flake dependency to update" 8 | pull-request-token: 9 | required: true 10 | description: "Access token used to create pull requests" 11 | pull-request-author: 12 | required: true 13 | description: "The author of the pull request" 14 | pull-request-merge-method: 15 | required: false 16 | description: "The merge method for automerging pull requests" 17 | default: "rebase" 18 | delete-branch: 19 | required: false 20 | default: "false" 21 | description: "Delete branch upon merge" 22 | github-token: 23 | required: false 24 | description: "Access token to increase the rate limit for GitHub API requests" 25 | pull-request-branch-prefix: 26 | required: false 27 | default: "create-pull-request/update-" 28 | description: "Prefix of the branch for the pull request" 29 | pull-request-labels: 30 | required: false 31 | description: "Labels to attach to the pull request" 32 | default: "" 33 | include-merge-commits: 34 | required: false 35 | description: "Whether to show merge commits in the log" 36 | default: "false" 37 | automerge: 38 | required: false 39 | description: "Whether to set the pull request to automatically merge on success. Requires that the automerge feature is enabled on GitHub." 40 | default: "false" 41 | runs: 42 | using: composite 43 | steps: 44 | - name: Get current commit 45 | id: get_current_commit 46 | uses: cpcloud/flake-dep-info-action@v2.0.11 47 | with: 48 | input: ${{ inputs.dependency }} 49 | 50 | - name: Update ${{ inputs.dependency }} 51 | shell: bash 52 | run: nix flake lock --update-input ${{ inputs.dependency }} 53 | 54 | - name: Get new commit 55 | id: get_new_commit 56 | uses: cpcloud/flake-dep-info-action@v2.0.11 57 | with: 58 | input: ${{ inputs.dependency }} 59 | 60 | - name: Get commit details for ${{ inputs.dependency }} changes 61 | uses: cpcloud/compare-commits-action@v5.0.37 62 | id: compare_commits 63 | if: ${{ steps.get_current_commit.outputs.rev != steps.get_new_commit.outputs.rev }} 64 | with: 65 | owner: ${{ steps.get_current_commit.outputs.owner }} 66 | repo: ${{ steps.get_current_commit.outputs.repo }} 67 | basehead: ${{ steps.get_current_commit.outputs.rev }}...${{ steps.get_new_commit.outputs.rev }} 68 | token: ${{ inputs.github-token }} 69 | include-merge-commits: ${{ fromJSON(inputs.include-merge-commits) }} 70 | 71 | - name: Create a pull request to update ${{ inputs.dependency }} 72 | if: ${{ steps.get_current_commit.outputs.rev != steps.get_new_commit.outputs.rev }} 73 | id: create_pr 74 | uses: peter-evans/create-pull-request@v6 75 | with: 76 | commit-message: "chore(flake/${{ inputs.dependency }}): ${{ steps.get_current_commit.outputs.short-rev }} -> ${{ steps.get_new_commit.outputs.short-rev }}" 77 | branch: "${{ inputs.pull-request-branch-prefix }}${{ inputs.dependency }}" 78 | delete-branch: ${{ fromJSON(inputs.delete-branch) }} 79 | author: ${{ inputs.pull-request-author }} 80 | title: "chore(flake/${{ inputs.dependency }}): `${{ steps.get_current_commit.outputs.short-rev }}` -> `${{ steps.get_new_commit.outputs.short-rev }}`" 81 | token: ${{ inputs.pull-request-token }} 82 | body: ${{ steps.compare_commits.outputs.differences }} 83 | labels: ${{ inputs.pull-request-labels }} 84 | 85 | - name: Set the PR to automerge 86 | if: ${{ steps.create_pr.outputs.pull-request-operation == 'created' && fromJSON(inputs.automerge) }} 87 | uses: peter-evans/enable-pull-request-automerge@v3 88 | with: 89 | token: ${{ inputs.pull-request-token }} 90 | pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} 91 | merge-method: ${{ inputs.pull-request-merge-method }} 92 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-compat": { 4 | "flake": false, 5 | "locked": { 6 | "lastModified": 1696426674, 7 | "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", 8 | "owner": "edolstra", 9 | "repo": "flake-compat", 10 | "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", 11 | "type": "github" 12 | }, 13 | "original": { 14 | "owner": "edolstra", 15 | "repo": "flake-compat", 16 | "type": "github" 17 | } 18 | }, 19 | "flake-utils": { 20 | "inputs": { 21 | "systems": "systems" 22 | }, 23 | "locked": { 24 | "lastModified": 1710146030, 25 | "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", 26 | "owner": "numtide", 27 | "repo": "flake-utils", 28 | "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", 29 | "type": "github" 30 | }, 31 | "original": { 32 | "owner": "numtide", 33 | "repo": "flake-utils", 34 | "type": "github" 35 | } 36 | }, 37 | "gitignore": { 38 | "inputs": { 39 | "nixpkgs": [ 40 | "pre-commit-hooks", 41 | "nixpkgs" 42 | ] 43 | }, 44 | "locked": { 45 | "lastModified": 1709087332, 46 | "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", 47 | "owner": "hercules-ci", 48 | "repo": "gitignore.nix", 49 | "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", 50 | "type": "github" 51 | }, 52 | "original": { 53 | "owner": "hercules-ci", 54 | "repo": "gitignore.nix", 55 | "type": "github" 56 | } 57 | }, 58 | "nixpkgs": { 59 | "locked": { 60 | "lastModified": 1711939449, 61 | "narHash": "sha256-k8HBuawAk2hWNzNkCiGebbStq3opqnyV1RdHXXojxNg=", 62 | "owner": "NixOS", 63 | "repo": "nixpkgs", 64 | "rev": "292a4d8fa11907f90eb2e9730b8cf2414f03bf58", 65 | "type": "github" 66 | }, 67 | "original": { 68 | "owner": "NixOS", 69 | "ref": "nixos-unstable-small", 70 | "repo": "nixpkgs", 71 | "type": "github" 72 | } 73 | }, 74 | "pre-commit-hooks": { 75 | "inputs": { 76 | "flake-compat": "flake-compat", 77 | "flake-utils": [ 78 | "flake-utils" 79 | ], 80 | "gitignore": "gitignore", 81 | "nixpkgs": [ 82 | "nixpkgs" 83 | ], 84 | "nixpkgs-stable": [ 85 | "nixpkgs" 86 | ] 87 | }, 88 | "locked": { 89 | "lastModified": 1711957905, 90 | "narHash": "sha256-8aEIBDbVyntFs0yzfo3uJ7SpvFoMABhAp4URoD8daZ0=", 91 | "owner": "cachix", 92 | "repo": "pre-commit-hooks.nix", 93 | "rev": "ffbf46949fcf41378498141341998b60fdbb2a32", 94 | "type": "github" 95 | }, 96 | "original": { 97 | "owner": "cachix", 98 | "repo": "pre-commit-hooks.nix", 99 | "type": "github" 100 | } 101 | }, 102 | "root": { 103 | "inputs": { 104 | "flake-utils": "flake-utils", 105 | "nixpkgs": "nixpkgs", 106 | "pre-commit-hooks": "pre-commit-hooks" 107 | } 108 | }, 109 | "systems": { 110 | "locked": { 111 | "lastModified": 1681028828, 112 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 113 | "owner": "nix-systems", 114 | "repo": "default", 115 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 116 | "type": "github" 117 | }, 118 | "original": { 119 | "owner": "nix-systems", 120 | "repo": "default", 121 | "type": "github" 122 | } 123 | } 124 | }, 125 | "root": "root", 126 | "version": 7 127 | } 128 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Update flakes using GitHub actions"; 3 | 4 | inputs = { 5 | flake-utils.url = "github:numtide/flake-utils"; 6 | 7 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; 8 | 9 | pre-commit-hooks = { 10 | url = "github:cachix/pre-commit-hooks.nix"; 11 | inputs = { 12 | nixpkgs.follows = "nixpkgs"; 13 | nixpkgs-stable.follows = "nixpkgs"; 14 | flake-utils.follows = "flake-utils"; 15 | }; 16 | }; 17 | }; 18 | 19 | outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }: 20 | flake-utils.lib.eachDefaultSystem (system: 21 | let 22 | pkgs = import nixpkgs { 23 | overlays = [ 24 | (final: _: { 25 | prettierTOML = final.writeShellApplication { 26 | name = "prettier"; 27 | text = '' 28 | ${final.nodePackages.prettier}/bin/prettier \ 29 | --plugin-search-dir "${final.nodePackages.prettier-plugin-toml}/lib" \ 30 | "$@" 31 | ''; 32 | }; 33 | }) 34 | ]; 35 | inherit system; 36 | }; 37 | inherit (pkgs.lib) mkForce; 38 | in 39 | { 40 | checks = { 41 | pre-commit-check = pre-commit-hooks.lib.${system}.run { 42 | src = ./.; 43 | hooks = { 44 | deadnix.enable = true; 45 | statix.enable = true; 46 | nixpkgs-fmt.enable = true; 47 | 48 | prettier = { 49 | enable = true; 50 | entry = mkForce "${pkgs.prettierTOML}/bin/prettier --check"; 51 | types_or = [ "json" "toml" "yaml" ]; 52 | }; 53 | }; 54 | }; 55 | }; 56 | 57 | devShell = pkgs.mkShell { 58 | name = "flake-update-action"; 59 | buildInputs = with pkgs; [ 60 | deadnix 61 | git 62 | nixpkgs-fmt 63 | prettierTOML 64 | statix 65 | ]; 66 | inherit (self.checks.${system}.pre-commit-check) shellHook; 67 | }; 68 | }); 69 | } 70 | --------------------------------------------------------------------------------