I have a self-hosted Github Action with the main function of running a bash script to deploy a Django site. I cd into the directory, and then execute the bash script. This works fine, and I can see the print statements (DEPLOY_FOLDER
AND CONTAINER_NAME
) from the bash script in the Github Action GUI.
name: Deploy Workflow
on:
workflow_dispatch:
jobs:
deploy:
runs-on: [self-hosted, emts]
steps:
- name: CD and then deploy
shell: bash
run: |
cd /export/home/scottc/
./deployserver.sh test test_deploy
HOWEVER, within my deployserver.sh
script, I am starting a (detached) TMUX new session. I receive a notice that my job completed successfully, but when I check tmux sessions (tmux ls
) after the job completes, I don't see any running.
#!/bin/bash
echo $1
echo $2
DEPLOY_FOLDER=$1
CONTAINER_NAME=$2
tmux new -d -s $CONTAINER_NAME -- pipenv run python server_web/run_server.py
I have updated the deployserver.sh
script to the below and found that a tmux session is actually being created, but must somehow get torn down when the job completes. I know this because after printing the DEPLOY_FOLDER
and CONTAINER_NAME
, I see tmux ls
prints test_deploy: 1 windows (created Thu May 18 11:00:49 2023) [80x24]
(while the job is still active but sleeping for 10 seconds). If I run tmux ls
on the server during those 10 seconds, I do see an active window. However when the 10 seconds completes and the Github Action ends, the tmux session dissapears with it.
#!/bin/bash
echo $1
echo $2
DEPLOY_FOLDER=$1
CONTAINER_NAME=$2
tmux new -d -s $CONTAINER_NAME -- pipenv run python server_web/run_server.py
sleep 3
tmux ls
sleep 10
What do I need to change for the tmux session to persist after the github action completes?