Telefonica / puppet-github-actions-runner

In This Repository you can find a module that will setup all of the files and configuration needed for GitHub Actions runner to work on Linux hosts (Ubuntu, Debian and CentOS).
Apache License 2.0
12 stars 15 forks source link

feat: add .env file support #40

Closed mrodm closed 2 years ago

mrodm commented 2 years ago

This PR adds the option to add customized environment variables per instance runner.

For instance, it could be used to add the environment variables mentioned in this doc to add cleanup scripts in runners.

Issue: https://github.com/Telefonica/puppet-github-actions-runner/issues/39

Adding as an example to the ".env" file the definition of the start hook

[/srv/actions-runner/repo]$ cat .env 
LANG=en_US.UTF-8
ACTIONS_RUNNER_HOOK_JOB_STARTED=/root/test.sh

Content of /root/test.sh

#!/bin/bash

echo "Testing hooks added by means of .env file"
echo "Current directory"
pwd

That variable was read and loaded by the runner, and its executions appears in the step "Set up runner" in all workflows:

A job started hook has been configured by the self-hosted runner administrator
Run '/root/test.sh'
Testing hooks added by means of .env file
Current directory
/srv/actions-runner/repo/_work/repo/repo

As a note, according to the few tests I've carried out, if other variables are added to .env file, they cannot be used as an environment variable in Github workflows.