Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
958240e9be | |||
d884d497b3 | |||
127c635f94 | |||
ae7e289a74 | |||
7a2785317e | |||
64a8cc193d | |||
127e3e96af | |||
7c39594b7e | |||
e26f7bb412 |
29
README.md
29
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
This is a GitHub Action that will update your flake.lock file whenever it is run.
|
||||
|
||||
> NOTE: We hardcode the `install_url` to a relatively recent `nixUnstable` (`nix-2.5pre20211015_130284b` currently). If you need a newer version that includes a new feature or important bug fix, feel free to file an issue or send a PR bumping the `install_url` inside the [`action.yml`](action.yml)!
|
||||
> **NOTE:** As of v3, this action will no longer automatically install Nix to the action runner. You **MUST** set up a Nix with flakes support enabled prior to running this action, or your workflow will not function as expected.
|
||||
|
||||
## Example
|
||||
|
||||
@ -11,7 +11,9 @@ An example GitHub Action workflow using this action would look like the followin
|
||||
```yaml
|
||||
name: update-flake-lock
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_dispatch: # allows manual triggering
|
||||
schedule:
|
||||
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
|
||||
|
||||
jobs:
|
||||
lockfile:
|
||||
@ -19,8 +21,27 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v14
|
||||
with:
|
||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install
|
||||
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Update flake.lock
|
||||
uses: DeterminateSystems/update-flake-lock@main
|
||||
uses: DeterminateSystems/update-flake-lock@v3
|
||||
```
|
||||
|
||||
## Running GitHub Actions CI
|
||||
|
||||
GitHub Actions will not run workflows when a branch is pushed by or a PR is opened by a GitHub Action. To work around this, try:
|
||||
|
||||
```
|
||||
git branch -D update_flake_lock_action
|
||||
git fetch origin
|
||||
git checkout update_flake_lock_action
|
||||
git commit --amend --no-edit
|
||||
git push origin update_flake_lock_action --force
|
||||
```
|
||||
|
||||
To have this workflow run on a recurring basis, see the [GitHub Actions documentation on the `schedule` key](https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#schedule).
|
||||
|
34
action.yml
34
action.yml
@ -3,11 +3,6 @@ description: 'Update your flake.lock and send a PR'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: cachix/install-nix-action@v14
|
||||
with:
|
||||
install_url: https://github.com/numtide/nix-unstable-installer/releases/download/nix-2.5pre20211015_130284b/install
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
- run: nix flake update --commit-lock-file
|
||||
shell: bash
|
||||
env:
|
||||
@ -15,10 +10,37 @@ runs:
|
||||
GIT_AUTHOR_EMAIL: <github-actions[bot]@users.noreply.github.com>
|
||||
GIT_COMMITTER_NAME: github-actions[bot]
|
||||
GIT_COMMITTER_EMAIL: <github-actions[bot]@users.noreply.github.com>
|
||||
- run: |
|
||||
content="$(git log --format=%b -n 1)"
|
||||
content="${content//'%'/'%25'}"
|
||||
content="${content//$'\n'/'%0A'}"
|
||||
content="${content//$'\r'/'%0D'}"
|
||||
echo "::set-output name=msg::$content"
|
||||
shell: bash
|
||||
id: commit_message
|
||||
- name: Create PR
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
branch: update_flake_lock_action
|
||||
delete-branch: true
|
||||
title: "flake.lock: Update"
|
||||
body: Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
|
||||
body: |
|
||||
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
|
||||
|
||||
```
|
||||
${{ steps.commit_message.outputs.msg }}
|
||||
```
|
||||
|
||||
### Running GitHub Actions on this PR
|
||||
|
||||
GitHub Actions will not run workflows on pull requests which are opened by a GitHub Action.
|
||||
|
||||
To run GitHub Actions workflows on this PR, run:
|
||||
|
||||
```sh
|
||||
git branch -D update_flake_lock_action
|
||||
git fetch origin
|
||||
git checkout update_flake_lock_action
|
||||
git commit --amend --no-edit
|
||||
git push origin update_flake_lock_action --force
|
||||
```
|
||||
|
Reference in New Issue
Block a user