Start/Restart Selfhosted Runner #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (C) 2024 Antonino Scordino | |
# Copyright (C) 2024 Souhrud Reddy | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# | |
name: Start/Restart Selfhosted Runner | |
on: | |
workflow_dispatch: | |
jobs: | |
run-devspace-and-tmux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Install 'tmux' | |
- name: Set up environment | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y tmux | |
# Download and configure 'crave'. | |
- name: Configure the 'crave' environment | |
run: | | |
if [[ "${DCDEVSPACE}" == "1" ]]; then | |
echo 'No need to set up crave, we are already running in devspace!' | |
else | |
mkdir ${HOME}/bin/ | |
curl -s https://raw.githubusercontent.com/accupara/crave/master/get_crave.sh | bash -s -- | |
mv ${PWD}/crave ${HOME}/bin/ | |
sudo ln -sf /home/${USER}/bin/crave /usr/bin/crave | |
envsubst < ${PWD}/crave.conf.sample >> ${PWD}/crave.conf | |
rm -rf ${PWD}/crave.conf.sample | |
fi | |
env: | |
CRAVE_USERNAME: ${{ secrets.CRAVE_USERNAME }} | |
CRAVE_TOKEN: ${{ secrets.CRAVE_TOKEN }} | |
# Start 'runner' in 'tmux'. | |
- name: Run crave devspace | |
run: | | |
echo "Looking for runner..." | |
# Look for whether there's a runner folder set up | |
if [ -f actions-runner/run.sh ] ; then | |
echo "Runner found! Restarting it..." | |
else | |
echo "Error! Runner not found!" | |
exit 1 | |
fi | |
crave ${{ secrets.CRAVE_FLAGS }} devspace -- "tmux kill-session -t ghactions || true | |
tmux new-session -d -s ghactions | |
tmux send-keys -t ghactions './actions-runner/run.sh' Enter | |
echo "Runner Started"" |