I was working on the deployment pipeline for a service that launches an app in a dedicated VM using GitHub Actions. In the last step of the workflow, the CI SSHs into the VM and runs several commands using a here document in bash. The simplified version looks like this:
# SSH into the remote machine and run commands to deploy the service
ssh $SSH_USER@$SSH_HOST <<EOF
# Go to the work directory
cd $WORK_DIR
# Make a git pull
git pull
# Export environment variables required for the service to run
export AUTH_TOKEN=$APP_AUTH_TOKEN
# Start the service
docker compose up -d --build
EOF
The fully working version can be found in the serve-init repo with here-doc.