-
Notifications
You must be signed in to change notification settings - Fork 22
Executing Scripts
Tartelet can execute scripts during the lifecycle of a virtual machine. Scripts that are run during a virtual machine's lifecycle should be located in the ~/.tartelet
folder on the virtual machine. This folder does not exist by default and must be manually created on the virtual machine.
Lifecycle Event | File Path | Description |
---|---|---|
Post-boot | ~/.tartelet/post-boot.sh |
The script is executed after the virtual machine has booted. |
Pre-run | ~/.tartelet/pre-run.sh |
The script is executed before a job in a workflow runs. |
Post-run | ~/.tartelet/post-run.sh |
The script is executed after all the steps in a job have run. |
Tartelet exposes some environment variables that are available to the scripts being run. Refer to the table below for the environment variables exposed by Tartelet and at which point in the lifecycle they are available.
Environment Variable | Lifecycle Events | Description |
---|---|---|
RUNNER_NAME |
Post-boot | The name of the runner. |
Recall that Tartelet destroys the virtual machine after a job has run, after which a new virtual machine is created and booted, and the lifecycle events are triggered again.
Follow the steps below to add a script to the virtual machine.
First, ensure that the virtual machines are not running by selecting Tartelet's menu bar item and then selecting "Stop".
Select Tartelet's menu bar item again and then select "Edit Virtual Machine". This will open the virtual machine.
Open Finder or the Terminal to create a folder at ~/.tartelet
if it does not already exist.
Finally, add to the script. It is key that the scripts are named as Tartelet expects. Refer to the table at the top of this document for the correct filenames.
For the sake of this example, we will add the two following two scripts.
pre-run.sh
#!/bin/bash
echo "🚀 The job is about to start."
post-run.sh
#!/bin/bash
echo "🏁 The job has ended."
We can now start the virtual machines again and verify that our pre- and post-run scripts work by starting a GitHub Actions job. Notice that we can see the output of the scripts in the "Set up runner" and "Complete runner" phases in the workflow's log on github.com.
Tartelet is built with ❤️ by Shape in Denmark. Oh, and we are hiring 🤗