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

Pass environment variables to script (fix #59) #62

Merged
merged 1 commit into from
Nov 12, 2022
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/test-environment_variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test import_github_env
on:
push:
branches:
- 'main'
- 'releases/**'
- 'w45-*'
pull_request:
workflow_dispatch:

jobs:
test_chroot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./ # pguyot/arm-runner-action@HEAD
with:
commands: |
[ -n "${CI}" ] && [ -n "${GITHUB_JOB}" ]
test_systemd_nspawn:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./ # pguyot/arm-runner-action@HEAD
with:
use_systemd_nspawn: true
systemd_nspawn_options: -E CI=${CI}
commands: |
[ -n "${CI}" ] && [ -z "${GITHUB_JOB:-}" ]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ image compression more efficient. Default is to optimize image.
Use `systemd-nspawn` instead of chroot to run commands. Default is to use
chroot.

#### `systemd_nspawn_options`

Additional options passed to `systemd-nspawn`. For example, `-E CI=${CI}` to pass
CI environment variable. See [systemd-nspawn(1)](https://manpages.ubuntu.com/manpages/focal/man1/systemd-nspawn.1.html).

#### `rootpartition`

Index (starting with 1) of the root partition. Default is 2, which is suitable
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ inputs:
description: 'Use systemd-nspawn instead of chroot'
required: false
default: 'no'
systemd_nspawn_options:
description: 'Options passed to systemd-nspawn, e.g. -E CI=${CI}'
required: false
default: ''
bootpartition:
description: 'Partition number for boot (/boot), empty means none'
required: false
Expand Down Expand Up @@ -223,9 +227,9 @@ runs:
ARM_RUNNER_INPUT_COMMANDS_EOF
if [ "${{ inputs.use_systemd_nspawn }}x" != "x" -a "${{ inputs.use_systemd_nspawn }}x" != "nox" ]; then
sudo apt-get install -y systemd-container
sudo systemd-nspawn -q -a --bind=${script_dir}:${chroot_script_dir} -D ${{ steps.mount_image.outputs.mount }} ${shell_path} ${shell_opts} ${chroot_script_dir}/commands.sh
sudo -E systemd-nspawn -q -a --bind=${script_dir}:${chroot_script_dir} -D ${{ steps.mount_image.outputs.mount }} ${{ inputs.systemd_nspawn_options }} ${shell_path} ${shell_opts} ${chroot_script_dir}/commands.sh
else
sudo chroot ${{ steps.mount_image.outputs.mount }} ${shell_path} ${shell_opts} ${chroot_script_dir}/commands.sh
sudo -E chroot ${{ steps.mount_image.outputs.mount }} ${shell_path} ${shell_opts} ${chroot_script_dir}/commands.sh
fi
rc=$?
[ -f ${script_dir}/github_env.sh ] && \
Expand Down