feat: Optimize A100 deployment script with refined environment and ex… #7
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
name: Deploy Application | |
on: | |
push: | |
branches: | |
- feat/deploy-actions # TODO: Change to main later | |
pull_request: | |
types: | |
- closed | |
branches: | |
- feat/deploy-actions # TODO: Change to main later | |
jobs: | |
deploy: | |
if: github.event.pull_request.merged == true || github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup SSH Config | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts | |
chmod 600 ~/.ssh/known_hosts | |
- name: Setup SSH Key | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Deploy to A100 Instance | |
env: | |
HOST: ${{ secrets.A100_HOST_2 }} | |
DEPLOY_USER: ${{ secrets.A100_USER }} | |
DEPLOY_PATH: ${{ secrets.A100_DEPLOY_PATH }} | |
run: | | |
ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$HOST "DEPLOY_PATH='${DEPLOY_PATH}' bash -s" << 'EOF' | |
# Load environment and Python | |
export PATH="/home/$USER/miniforge3/bin:$PATH" | |
source ~/.bashrc | |
source /home/$USER/miniforge3/bin/activate | |
# Navigate and setup deployment | |
sudo chown -R $DEPLOY_USER:$DEPLOY_USER $DEPLOY_PATH | |
cd $DEPLOY_PATH | |
sudo git stash | |
git fetch origin feat/deploy-actions | |
git reset --hard origin/feat/deploy-actions | |
# Make scripts executable | |
chmod +x ./docker-ctl.sh | |
# Your deployment commands | |
docker compose -f docker-compose.yml build --no-cache | |
./docker-ctl.sh down | |
sudo -E bash launch.sh | |
echo "Deployment completed at $(date)" | |
EOF | |
- name: Deployment Status | |
if: always() | |
run: | | |
if [ "${{ job.status }}" == "success" ]; then | |
echo "✅ Deployment successful to A100 Instance" | |
else | |
echo "❌ Deployment failed for A100 Instance" | |
fi |