fix: Use tilde expansion and escape variables for remote execution
This commit is contained in:
parent
e8ef0710a2
commit
edffa1f249
@ -187,41 +187,40 @@ jobs:
|
|||||||
|
|
||||||
- name: Deploy to CT109
|
- name: Deploy to CT109
|
||||||
run: |
|
run: |
|
||||||
export GITEA_TOKEN="${{ secrets.SECRET }}"
|
|
||||||
ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} bash -s << ENDSSH
|
ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} bash -s << ENDSSH
|
||||||
set -e
|
set -e
|
||||||
export VERSION="${{ github.sha }}"
|
export VERSION="${{ github.sha }}"
|
||||||
export GITEA_TOKEN="$GITEA_TOKEN"
|
export GITEA_TOKEN="${{ secrets.SECRET }}"
|
||||||
|
|
||||||
# Use home directory for deployment
|
# Use home directory for deployment
|
||||||
DEPLOY_DIR="$HOME/littleshop"
|
DEPLOY_DIR=~/littleshop
|
||||||
echo "Using deployment directory: $DEPLOY_DIR"
|
echo "Using deployment directory: \$DEPLOY_DIR"
|
||||||
|
|
||||||
# Create deployment directory if it doesn't exist
|
# Create deployment directory if it doesn't exist
|
||||||
mkdir -p "$DEPLOY_DIR"
|
mkdir -p "\$DEPLOY_DIR"
|
||||||
cd "$DEPLOY_DIR"
|
cd "\$DEPLOY_DIR"
|
||||||
|
|
||||||
# Clone or pull latest code
|
# Clone or pull latest code
|
||||||
if [ ! -d .git ]; then
|
if [ ! -d .git ]; then
|
||||||
echo "Cloning repository with authentication..."
|
echo "Cloning repository with authentication..."
|
||||||
rm -rf * # Clean any existing files
|
rm -rf * # Clean any existing files
|
||||||
git clone https://oauth2:${GITEA_TOKEN}@git.silverlabs.uk/Jamie/littleshop.git .
|
git clone https://oauth2:\${GITEA_TOKEN}@git.silverlabs.uk/Jamie/littleshop.git .
|
||||||
else
|
else
|
||||||
echo "Repository already cloned, pulling latest..."
|
echo "Repository already cloned, pulling latest..."
|
||||||
git fetch origin
|
git fetch origin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking out version: $VERSION"
|
echo "Checking out version: \$VERSION"
|
||||||
git checkout $VERSION || git checkout main
|
git checkout \$VERSION || git checkout main
|
||||||
|
|
||||||
# Build images on CT109
|
# Build images on CT109
|
||||||
echo "Building LittleShop image..."
|
echo "Building LittleShop image..."
|
||||||
docker build --no-cache -t littleshop:$VERSION .
|
docker build --no-cache -t littleshop:\$VERSION .
|
||||||
docker tag littleshop:$VERSION littleshop:latest
|
docker tag littleshop:\$VERSION littleshop:latest
|
||||||
|
|
||||||
echo "Building TeleBot image..."
|
echo "Building TeleBot image..."
|
||||||
docker build --no-cache -t telebot:$VERSION -f Dockerfile.telebot .
|
docker build --no-cache -t telebot:\$VERSION -f Dockerfile.telebot .
|
||||||
docker tag telebot:$VERSION telebot:latest
|
docker tag telebot:\$VERSION telebot:latest
|
||||||
|
|
||||||
# Stop existing containers
|
# Stop existing containers
|
||||||
echo "Stopping existing containers..."
|
echo "Stopping existing containers..."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user