Compare commits
12 Commits
v17
...
flake-chec
Author | SHA1 | Date | |
---|---|---|---|
8c780fa98c | |||
957598f6bb | |||
867838943c | |||
dec3bc3c9b | |||
ad81b423ab | |||
c7487e8c98 | |||
54eb0b2901 | |||
8a88a06550 | |||
9af2d0f36a | |||
b55ee105d9 | |||
bc75a5b55e | |||
786e5cf5a2 |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -11,6 +11,10 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check Nixpkgs input
|
||||
uses: DeterminateSystems/flake-checker-action@v4
|
||||
with:
|
||||
fail-mode: true
|
||||
- name: Install Nix
|
||||
uses: DeterminateSystems/nix-installer-action@main
|
||||
- name: Shellcheck
|
||||
|
25
README.md
25
README.md
@ -59,6 +59,31 @@ jobs:
|
||||
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@v2
|
||||
- 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
|
||||
|
||||
```yaml
|
||||
|
28
action.yml
28
action.yml
@ -13,6 +13,9 @@ inputs:
|
||||
description: 'The message provided with the commit'
|
||||
required: false
|
||||
default: "flake.lock: Update"
|
||||
base:
|
||||
description: "Sets the pull request base branch. Defaults to the branch checked out in the workflow."
|
||||
required: false
|
||||
branch:
|
||||
description: 'The branch of the PR to be created'
|
||||
required: false
|
||||
@ -92,10 +95,17 @@ inputs:
|
||||
description: 'GPG Private Key Passphrase for the GPG Private Key with which to sign the commits in the PR to be created'
|
||||
required: false
|
||||
default: ''
|
||||
nix-options:
|
||||
description: 'A space-separated list of options to pass to the nix command'
|
||||
required: false
|
||||
default: ''
|
||||
outputs:
|
||||
pull-request-number:
|
||||
description: 'The number of the opened pull request'
|
||||
value: ${{ steps.create-pr.outputs.pull-request-number }}
|
||||
pull-request-operation:
|
||||
description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.'
|
||||
value: ${{ steps.create-pr.outputs.pull-request-operation }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@ -140,6 +150,7 @@ runs:
|
||||
GIT_AUTHOR_EMAIL: ${{ env.GIT_AUTHOR_EMAIL }}
|
||||
GIT_COMMITTER_NAME: ${{ env.GIT_COMMITTER_NAME }}
|
||||
GIT_COMMITTER_EMAIL: ${{ env.GIT_COMMITTER_EMAIL }}
|
||||
NIX_OPTIONS: ${{ inputs.nix-options }}
|
||||
TARGETS: ${{ inputs.inputs }}
|
||||
COMMIT_MSG: ${{ inputs.commit-msg }}
|
||||
PATH_TO_FLAKE_DIR: ${{ inputs.path-to-flake-dir }}
|
||||
@ -152,12 +163,12 @@ runs:
|
||||
- name: Set additional env variables (GIT_COMMIT_MESSAGE)
|
||||
shell: bash
|
||||
run: |
|
||||
GIT_COMMIT_MESSAGE="$(git log --format=%b -n 1)"
|
||||
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//'%'/'%25'}"
|
||||
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//$'\n'/'%0A'}"
|
||||
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//$'\r'/'%0D'}"
|
||||
echo "GIT_COMMIT_MESSAGE=$GIT_COMMIT_MESSAGE" >> $GITHUB_ENV
|
||||
echo "GIT_COMMIT_MESSAGE is: ${GIT_COMMIT_MESSAGE}"
|
||||
DELIMITER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
||||
COMMIT_MESSAGE="$(git log --format=%b -n 1)"
|
||||
echo "GIT_COMMIT_MESSAGE<<$DELIMITER" >> $GITHUB_ENV
|
||||
echo "$COMMIT_MESSAGE" >> $GITHUB_ENV
|
||||
echo "$DELIMITER" >> $GITHUB_ENV
|
||||
echo "GIT_COMMIT_MESSAGE is: ${COMMIT_MESSAGE}"
|
||||
- name: Interpolate PR Body
|
||||
uses: pedrolamas/handlebars-action@v2.2.0
|
||||
with:
|
||||
@ -165,7 +176,7 @@ runs:
|
||||
output-filename: 'pr_body.txt'
|
||||
- name: Read pr_body.txt
|
||||
id: pr_body
|
||||
uses: andstor/file-reader-action@v1
|
||||
uses: juliangruber/read-file-action@v1
|
||||
with:
|
||||
path: "pr_body.txt"
|
||||
# We need to remove the pr_body files so that the
|
||||
@ -178,6 +189,7 @@ runs:
|
||||
id: create-pr
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
base: ${{ inputs.base }}
|
||||
branch: ${{ inputs.branch }}
|
||||
delete-branch: true
|
||||
committer: ${{ env.GIT_COMMITTER_NAME }} ${{ env.GIT_COMMITTER_EMAIL }}
|
||||
@ -187,4 +199,4 @@ runs:
|
||||
assignees: ${{ inputs.pr-assignees }}
|
||||
labels: ${{ inputs.pr-labels }}
|
||||
reviewers: ${{ inputs.pr-reviewers }}
|
||||
body: ${{ steps.pr_body.outputs.contents }}
|
||||
body: ${{ steps.pr_body.outputs.content }}
|
||||
|
6
flake.lock
generated
6
flake.lock
generated
@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1659131907,
|
||||
"narHash": "sha256-8bz4k18M/FuVC+EVcI4aREN2PsEKT7LGmU2orfjnpCg=",
|
||||
"lastModified": 1686869522,
|
||||
"narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8d435fca5c561da8168abb30270788d2da2a7951",
|
||||
"rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -5,12 +5,19 @@ if [[ -n "$PATH_TO_FLAKE_DIR" ]]; then
|
||||
cd "$PATH_TO_FLAKE_DIR"
|
||||
fi
|
||||
|
||||
options=()
|
||||
if [[ -n "$NIX_OPTIONS" ]]; then
|
||||
for option in $NIX_OPTIONS; do
|
||||
options+=("${option}")
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -n "$TARGETS" ]]; then
|
||||
inputs=()
|
||||
for input in $TARGETS; do
|
||||
inputs+=("--update-input" "$input")
|
||||
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
|
||||
nix flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
|
||||
nix "${options[@]}" flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user