Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
da2fd6f256 | |||
fd510d25c0 | |||
1a057b79b1 | |||
51e1459968 | |||
4fbf969957 | |||
55ddfbef62 | |||
dec3bc3c9b | |||
ad81b423ab | |||
c7487e8c98 | |||
54eb0b2901 | |||
8a88a06550 | |||
9af2d0f36a | |||
b55ee105d9 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -13,5 +13,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@main
|
uses: DeterminateSystems/nix-installer-action@main
|
||||||
|
- name: Enable magic Nix cache
|
||||||
|
uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- name: Shellcheck
|
- name: Shellcheck
|
||||||
run: nix-shell --run 'shellcheck $(find . -type f -name "*.sh" -executable)'
|
run: nix-shell --run 'shellcheck $(find . -type f -name "*.sh" -executable)'
|
||||||
|
10
.github/workflows/update.yml
vendored
10
.github/workflows/update.yml
vendored
@ -2,15 +2,19 @@ name: update-flake-lock
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * 0"
|
- cron: '0 0 * * 0'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lockfile:
|
lockfile:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@main
|
uses: DeterminateSystems/nix-installer-action@main
|
||||||
|
- name: Enable magic Nix cache
|
||||||
|
uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
- name: Check flake
|
||||||
|
uses: DeterminateSystems/flake-checker-action@main
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
uses: ./.
|
uses: ./.
|
||||||
|
41
README.md
41
README.md
@ -20,7 +20,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -50,7 +50,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -59,6 +59,31 @@ jobs:
|
|||||||
inputs: input1 input2 input3
|
inputs: input1 input2 input3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Example adding options to nix command
|
||||||
|
|
||||||
|
It is also possible to use specific options to the nix command in a space separated list:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: update-flake-lock
|
||||||
|
on:
|
||||||
|
workflow_dispatch: # allows manual triggering
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lockfile:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Install Nix
|
||||||
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
|
- name: Update flake.lock
|
||||||
|
uses: DeterminateSystems/update-flake-lock@vX
|
||||||
|
with:
|
||||||
|
nix-options: --debug --log-format raw
|
||||||
|
```
|
||||||
|
|
||||||
## Example that prints the number of the created PR
|
## Example that prints the number of the created PR
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -73,7 +98,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -102,7 +127,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -129,7 +154,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -174,7 +199,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -209,7 +234,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
@ -271,7 +296,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v1
|
uses: DeterminateSystems/nix-installer-action@v1
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
|
25
action.yml
25
action.yml
@ -1,5 +1,5 @@
|
|||||||
name: 'Update flake.lock'
|
name: 'Update Nix Flake Lock'
|
||||||
description: 'Update your flake.lock and send a PR'
|
description: 'Update your Nix flake.lock and send a PR'
|
||||||
inputs:
|
inputs:
|
||||||
inputs:
|
inputs:
|
||||||
description: 'A space-separated list of inputs to update. Leave empty to update all inputs.'
|
description: 'A space-separated list of inputs to update. Leave empty to update all inputs.'
|
||||||
@ -95,6 +95,10 @@ inputs:
|
|||||||
description: 'GPG Private Key Passphrase for the GPG Private Key with which to sign the commits in the PR to be created'
|
description: 'GPG Private Key Passphrase for the GPG Private Key with which to sign the commits in the PR to be created'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
nix-options:
|
||||||
|
description: 'A space-separated list of options to pass to the nix command'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
outputs:
|
outputs:
|
||||||
pull-request-number:
|
pull-request-number:
|
||||||
description: 'The number of the opened pull request'
|
description: 'The number of the opened pull request'
|
||||||
@ -146,6 +150,7 @@ runs:
|
|||||||
GIT_AUTHOR_EMAIL: ${{ env.GIT_AUTHOR_EMAIL }}
|
GIT_AUTHOR_EMAIL: ${{ env.GIT_AUTHOR_EMAIL }}
|
||||||
GIT_COMMITTER_NAME: ${{ env.GIT_COMMITTER_NAME }}
|
GIT_COMMITTER_NAME: ${{ env.GIT_COMMITTER_NAME }}
|
||||||
GIT_COMMITTER_EMAIL: ${{ env.GIT_COMMITTER_EMAIL }}
|
GIT_COMMITTER_EMAIL: ${{ env.GIT_COMMITTER_EMAIL }}
|
||||||
|
NIX_OPTIONS: ${{ inputs.nix-options }}
|
||||||
TARGETS: ${{ inputs.inputs }}
|
TARGETS: ${{ inputs.inputs }}
|
||||||
COMMIT_MSG: ${{ inputs.commit-msg }}
|
COMMIT_MSG: ${{ inputs.commit-msg }}
|
||||||
PATH_TO_FLAKE_DIR: ${{ inputs.path-to-flake-dir }}
|
PATH_TO_FLAKE_DIR: ${{ inputs.path-to-flake-dir }}
|
||||||
@ -158,12 +163,12 @@ runs:
|
|||||||
- name: Set additional env variables (GIT_COMMIT_MESSAGE)
|
- name: Set additional env variables (GIT_COMMIT_MESSAGE)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
GIT_COMMIT_MESSAGE="$(git log --format=%b -n 1)"
|
DELIMITER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
||||||
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//'%'/'%25'}"
|
COMMIT_MESSAGE="$(git log --format=%b -n 1)"
|
||||||
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//$'\n'/'%0A'}"
|
echo "GIT_COMMIT_MESSAGE<<$DELIMITER" >> $GITHUB_ENV
|
||||||
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//$'\r'/'%0D'}"
|
echo "$COMMIT_MESSAGE" >> $GITHUB_ENV
|
||||||
echo "GIT_COMMIT_MESSAGE=$GIT_COMMIT_MESSAGE" >> $GITHUB_ENV
|
echo "$DELIMITER" >> $GITHUB_ENV
|
||||||
echo "GIT_COMMIT_MESSAGE is: ${GIT_COMMIT_MESSAGE}"
|
echo "GIT_COMMIT_MESSAGE is: ${COMMIT_MESSAGE}"
|
||||||
- name: Interpolate PR Body
|
- name: Interpolate PR Body
|
||||||
uses: pedrolamas/handlebars-action@v2.2.0
|
uses: pedrolamas/handlebars-action@v2.2.0
|
||||||
with:
|
with:
|
||||||
@ -171,7 +176,7 @@ runs:
|
|||||||
output-filename: 'pr_body.txt'
|
output-filename: 'pr_body.txt'
|
||||||
- name: Read pr_body.txt
|
- name: Read pr_body.txt
|
||||||
id: pr_body
|
id: pr_body
|
||||||
uses: andstor/file-reader-action@v1
|
uses: juliangruber/read-file-action@v1
|
||||||
with:
|
with:
|
||||||
path: "pr_body.txt"
|
path: "pr_body.txt"
|
||||||
# We need to remove the pr_body files so that the
|
# We need to remove the pr_body files so that the
|
||||||
@ -194,4 +199,4 @@ runs:
|
|||||||
assignees: ${{ inputs.pr-assignees }}
|
assignees: ${{ inputs.pr-assignees }}
|
||||||
labels: ${{ inputs.pr-labels }}
|
labels: ${{ inputs.pr-labels }}
|
||||||
reviewers: ${{ inputs.pr-reviewers }}
|
reviewers: ${{ inputs.pr-reviewers }}
|
||||||
body: ${{ steps.pr_body.outputs.contents }}
|
body: ${{ steps.pr_body.outputs.content }}
|
||||||
|
@ -5,12 +5,19 @@ if [[ -n "$PATH_TO_FLAKE_DIR" ]]; then
|
|||||||
cd "$PATH_TO_FLAKE_DIR"
|
cd "$PATH_TO_FLAKE_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
options=()
|
||||||
|
if [[ -n "$NIX_OPTIONS" ]]; then
|
||||||
|
for option in $NIX_OPTIONS; do
|
||||||
|
options+=("${option}")
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$TARGETS" ]]; then
|
if [[ -n "$TARGETS" ]]; then
|
||||||
inputs=()
|
inputs=()
|
||||||
for input in $TARGETS; do
|
for input in $TARGETS; do
|
||||||
inputs+=("--update-input" "$input")
|
inputs+=("--update-input" "$input")
|
||||||
done
|
done
|
||||||
nix flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
|
nix "${options[@]}" flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
|
||||||
else
|
else
|
||||||
nix flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
|
nix "${options[@]}" flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user