Skip to content

Merge pull request #47 from SoftBananas/ci-cd #33

Merge pull request #47 from SoftBananas/ci-cd

Merge pull request #47 from SoftBananas/ci-cd #33

Workflow file for this run

name: Deploy
on:
push:
branches: [ main-banana ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- 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: Checkout repository
uses: actions/checkout@v2
- name: Install sshpass
run: sudo apt-get install -y sshpass
- name: Copy docker-compose.yml to server
run: scp -o StrictHostKeyChecking=no -P ${{ secrets.SERVER_PORT }} docker-compose.yml ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}:/home/ivan/teamapp/docker-compose.yml
- name: Deploy to server
run: |
sshpass -p ${{ secrets.SERVER_PASSWORD }} ssh -o StrictHostKeyChecking=no -p ${{ secrets.SERVER_PORT }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }} "cd /home/ivan/teamapp/ && docker-compose up -d"