-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaction.yml
More file actions
48 lines (42 loc) · 2.11 KB
/
Copy pathaction.yml
File metadata and controls
48 lines (42 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: emulate
description: Emulate unsupported operating systems using QEMU.
inputs:
operating-system:
description: The operating-system specifier.
required: true
runs:
using: composite
steps:
- name: Boot guest ${{ inputs.operating-system }}.
shell: bash
working-directory: ${{ runner.temp }}
env:
EMULATE_OPERATING_SYSTEM: ${{ inputs.operating-system }}
run: |
# Install Vagrant, VirtualBox
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update --quiet --quiet
sudo apt-get install --quiet --quiet vagrant virtualbox
case "$EMULATE_OPERATING_SYSTEM" in
openbsd-latest) EMULATE_OPERATING_SYSTEM=openbsd-7.6 ;;
freebsd-latest) EMULATE_OPERATING_SYSTEM=freebsd-14.2 ;;
netbsd-latest) EMULATE_OPERATING_SYSTEM=netbsd-10.1 ;;
esac
# By default, Vagrant uses the current directory you are in. The working
# directory is important because it is where Vagrant looks for the Vagrantfile.
# VAGRANT_CWD can be set to change the working directory to the Vagrantfile.
VAGRANT_CWD="$GITHUB_ACTION_PATH/$EMULATE_OPERATING_SYSTEM"
EMULATE_BASH_HIJACKER="$(mktemp)"
# It's important to delete the BASH_ENV environment variable once we've
# used it to "hijack" the first bash(1) process, because we don't want to
# continue hijacking the rest of the process tree.
cat >"$EMULATE_BASH_HIJACKER" <<EOF
unset BASH_ENV
VAGRANT_CWD="$VAGRANT_CWD" exec vagrant ssh < "\$0"
EOF
# Set $BASH_ENV to execute our "hijack" script before the BSD commands are
# executed in an Ubuntu Linux bash process.
# https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
echo "BASH_ENV=$EMULATE_BASH_HIJACKER" >> "$GITHUB_ENV"
VAGRANT_CWD="$VAGRANT_CWD" vagrant up