Skip to content

Merge pull request #49 from SoftBananas/ci-cd #35

Merge pull request #49 from SoftBananas/ci-cd

Merge pull request #49 from SoftBananas/ci-cd #35

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: Install sshpass
run: sudo apt-get install -y sshpass
- name: Copy docker-compose.yml to server
run: scp -P ${{ secrets.SERVER_PORT }} docker-compose.yml ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}:${{ secrets.SERVER_PATH }}/docker-compose.yml
- name: Deploy to server
run: |
sshpass -p ${{ secrets.SERVER_PASSWORD }} ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }} "cd ${{ secrets.SERVER_PATH }}/ && docker-compose up -d"