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

Allow to run without sudo #33

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kill_xvfb () {
local xvfb_pids=`ps aux | grep tmp/xvfb-run | grep -v grep | awk '{print $2}'`
if [ "$xvfb_pids" != "" ]; then
echo "Killing the following xvfb processes: $xvfb_pids"
sudo kill $xvfb_pids
kill $xvfb_pids
else
echo "No xvfb processes to kill"
fi
Expand Down
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ async function main() {

try {
if (process.platform == "linux") {
await exec.exec("sudo apt-get install -y xvfb");
try {
await exec.exec(`sudo apt-get install -y xvfb`);
} catch(error) {
core.debug("Failed to install xvfb with sudo, trying without");
await exec.exec(`apt-get install -y xvfb`);
}
}

const commands = core.getInput('run', { required: true }).split("\n");
Expand Down Expand Up @@ -39,9 +44,13 @@ async function runCommandWithXvfb(command, directory, options) {

async function cleanUpXvfb() {
try {
await exec.exec("bash", [`${__dirname}/cleanup.sh`]);
try {
await exec.exec("bash", [`sudo ${__dirname}/cleanup.sh`]);
} catch {
await exec.exec("bash", [`${__dirname}/cleanup.sh`]);
}
} catch {

core.debug('Cleanup failed');
}
}

Expand Down