Skip to content

Commit

Permalink
Update digitalocean-deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
3xjn authored Oct 14, 2024
1 parent 2a5879a commit 1c3d564
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/digitalocean-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,44 @@ jobs:
set -e
echo "Starting deployment process..."
# Change to the directory where docker-compose.yml is located
cd /home/${{ secrets.DROPLET_USERNAME }}
echo "Current Directory: \$(pwd)"
echo "Contents of the Directory:"
ls -l
# Stop and remove the existing container
echo "Stopping existing container if it exists..."
if [ "\$(sudo docker ps -q -f name=todo-app)" ]; then
sudo docker-compose down
fi
echo "Loading Docker image..."
if [ -f /home/${{ secrets.DROPLET_USERNAME }}/image.tar ]; then
sudo docker load -i /home/${{ secrets.DROPLET_USERNAME }}/image.tar
else
echo "image.tar not found, skipping load step"
fi
echo "Loaded Docker images:"
sudo docker images
echo "Running Docker Compose..."
export IMAGE_TAG=${{ env.IMAGE_TAG }}
export CERT_PEM=\$(sudo cat /etc/letsencrypt/live/3xjn.dev/fullchain.pem)
export KEY_PEM=\$(sudo cat /etc/letsencrypt/live/3xjn.dev/privkey.pem)
# Export MongoDB environment variables
export MONGO_CONNECTION_STRING="${{ secrets.MONGO_CONNECTION_STRING }}"
export MONGO_DATABASE_NAME="${{ secrets.MONGO_DATABASE_NAME }}"
export MONGO_COLLECTION_NAME="${{ secrets.MONGO_COLLECTION_NAME }}"
sudo IMAGE_TAG=\$IMAGE_TAG CERT_PEM="\$CERT_PEM" KEY_PEM="\$KEY_PEM" sudo docker-compose up -d
# Run the Docker Compose command
sudo IMAGE_TAG=\$IMAGE_TAG CERT_PEM="\$CERT_PEM" KEY_PEM="\$KEY_PEM" \
MONGO_CONNECTION_STRING="\$MONGO_CONNECTION_STRING" \
MONGO_DATABASE_NAME="\$MONGO_DATABASE_NAME" \
MONGO_COLLECTION_NAME="\$MONGO_COLLECTION_NAME" \
sudo docker-compose up -d
echo "Deployment completed successfully!"
EOF

0 comments on commit 1c3d564

Please sign in to comment.