From bd4819cdc67612000d3b023abd1dbbc7c80a2419 Mon Sep 17 00:00:00 2001 From: David Bieber Date: Tue, 3 Dec 2024 19:12:14 -0500 Subject: [PATCH 1/3] Add non_image_commands to action --- README.md | 4 ++++ action.yml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index dac5037..97d9163 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ deleted on cleanup. ### Inputs +#### `non_image_commands` + +Commands to execute outside the image after the repo has been copied/mounted into the image, but before the image commands run. Optional. + #### `commands` Commands to execute. Written to a script within the image. Required. diff --git a/action.yml b/action.yml index 8082fdb..de18e1f 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,9 @@ inputs: description: 'Path to cpu info file to be mounted on /proc/cpuinfo' required: false default: '' + non_image_commands: + description: 'Commands to run outside the image, executed with /bin/sh' + required: false commands: description: 'Commands to run in the image, executed with /bin/sh' required: true @@ -219,6 +222,9 @@ runs: sudo cp -Rp ${{ github.workspace }} ${{ steps.mount_image.outputs.mount }}${repository_path} ;; esac + if [ "${{ inputs.non_image_commands }}x" != "x" ]; then + ${{ inputs.non_image_commands }} + fi if [ "${{ inputs.use_systemd_nspawn }}x" != "x" -a "${{ inputs.use_systemd_nspawn }}x" != "nox" ]; then chroot_script_dir=/scripts script_dir=${RUNNER_TEMP:-/home/actions/temp}/scripts From b6ffe77ca6374a1cbcf77cee71f6671c99bedafe Mon Sep 17 00:00:00 2001 From: David Bieber Date: Tue, 3 Dec 2024 19:52:39 -0500 Subject: [PATCH 2/3] Write to script then run --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index de18e1f..3673c76 100644 --- a/action.yml +++ b/action.yml @@ -223,7 +223,12 @@ runs: ;; esac if [ "${{ inputs.non_image_commands }}x" != "x" ]; then + mkdir -p ${script_dir} + script_path=${script_dir}/non_image_commands.sh + cat >> ${script_path} <<"INPUT_COMMANDS_EOF" ${{ inputs.non_image_commands }} + INPUT_COMMANDS_EOF + /bin/sh $script_path fi if [ "${{ inputs.use_systemd_nspawn }}x" != "x" -a "${{ inputs.use_systemd_nspawn }}x" != "nox" ]; then chroot_script_dir=/scripts From d449539a4f782b6b812116407dd1792474f263ca Mon Sep 17 00:00:00 2001 From: David Bieber Date: Tue, 3 Dec 2024 20:04:34 -0500 Subject: [PATCH 3/3] Fix heredoc --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 3673c76..2e5e6e8 100644 --- a/action.yml +++ b/action.yml @@ -223,11 +223,11 @@ runs: ;; esac if [ "${{ inputs.non_image_commands }}x" != "x" ]; then - mkdir -p ${script_dir} script_path=${script_dir}/non_image_commands.sh + mkdir -p ${script_dir} cat >> ${script_path} <<"INPUT_COMMANDS_EOF" - ${{ inputs.non_image_commands }} - INPUT_COMMANDS_EOF + ${{ inputs.non_image_commands }} + INPUT_COMMANDS_EOF /bin/sh $script_path fi if [ "${{ inputs.use_systemd_nspawn }}x" != "x" -a "${{ inputs.use_systemd_nspawn }}x" != "nox" ]; then