From a10510d38318b25dd37d5d9ad92230364e93db73 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Sun, 3 Apr 2022 18:26:19 +0200 Subject: [PATCH] Add: script for `update flake lock` Take commands out of the `action.yml` file, and put it in a dedicated shell script. --- action.yml | 13 +++---------- update-flake-lock.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100755 update-flake-lock.sh diff --git a/action.yml b/action.yml index b8d9032..3386bb8 100644 --- a/action.yml +++ b/action.yml @@ -24,22 +24,15 @@ inputs: runs: using: "composite" steps: - - run: | - if [[ -n '${{ inputs.inputs }}' ]]; then - inputs=() - for input in ${{ inputs.inputs }}; do - inputs+=("--update-input" "$input") - done - nix flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "${{ inputs.commit-msg }}" - else - nix flake update --commit-lock-file --commit-lockfile-summary "${{ inputs.commit-msg }}" - fi + - run: $GITHUB_ACTION_PATH/update-flake-lock.sh shell: bash env: GIT_AUTHOR_NAME: github-actions[bot] GIT_AUTHOR_EMAIL: GIT_COMMITTER_NAME: github-actions[bot] GIT_COMMITTER_EMAIL: + TARGETS: ${{ inputs.inputs }} + COMMIT_MSG: ${{ inputs.commit-msg }} - run: | content="$(git log --format=%b -n 1)" content="${content//'%'/'%25'}" diff --git a/update-flake-lock.sh b/update-flake-lock.sh new file mode 100755 index 0000000..c191dfa --- /dev/null +++ b/update-flake-lock.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +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" +else + nix flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG" +fi