Skip to content

fix: deploy.yml

fix: deploy.yml #75

Workflow file for this run

name: Deploy
on:
push:
branches: [ main-banana ]
env:
SERVER_HOST: 109.172.81.237
SERVER_PORT: 22
SERVER_USER: root
SERVER_PATH: /home/teamapp
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
touch .env.prod
echo "${{ secrets.ENV }}" > .env.prod
docker-compose -f docker-compose.yml build
docker-compose -f docker-compose.yml push
- name: SSH Connection
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ../private.key
sudo chmod 600 ../private.key
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
echo "${{ secrets.SSH_PASSPHRASE }}" | ssh-agent bash -c "ssh-add ../private.key; ssh -o StrictHostKeyChecking=no -tt ${{ env.SERVER_USER }}@${{ env.SERVER_HOST }}"
echo "Connected"
shell: bash
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_KEY}}
SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}}
SSH_KEY_PATH: ${{ github.workspace }}/../private.key