Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non_image_commands to action #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -219,6 +222,14 @@ runs:
sudo cp -Rp ${{ github.workspace }} ${{ steps.mount_image.outputs.mount }}${repository_path}
;;
esac
if [ "${{ inputs.non_image_commands }}x" != "x" ]; then
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
/bin/sh $script_path
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
Expand Down