diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9ec6993..3837291 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,7 +2,8 @@ name: build on: push: branches: - - "*" + - dev + - main paths-ignore: - "README.md" workflow_dispatch: diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..dc530c8 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: deploy +on: + push: + branches: + - main + workflow_run: + workflows: [build] + types: + - completed + workflow_dispatch: + +env: + IMAGE_TAG: ${{ github.sha }} + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - name: Set up SSH private key. + run: eval "$(ssh-agent -s)" + - run: mkdir -p ~/.ssh + - run: ssh-keyscan ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts + - run: ssh-agent -a $SSH_AUTH_SOCK > /dev/null + - run: ssh-add - <<< "${{ secrets.SSH_KEY }}" + + - name: Update docker compose + run: | + ssh $SSH_USER@$SSH_HOST "cd YetAnotherCalendar/ && YET_ANOTHER_CALENDAR_VERSION=$IMAGE_TAG docker compose up -d --build" + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 388c996..a7ef229 100644 --- a/.gitignore +++ b/.gitignore @@ -124,6 +124,7 @@ celerybeat.pid *.sage.py # Environments +.env.version frontend/.env .venv env/ diff --git a/docker-compose.yaml b/docker-compose.yaml index b989878..5b03b63 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,15 +1,14 @@ services: - api: &main_app + api: ports: - "8000:8000" build: context: backend/ dockerfile: Dockerfile - image: ghcr.io/azamatkomaev/yet_another_calendar_backend:${YET_ANOTHER_CALENDAR_VERSION:-dev} + image: ghcr.io/azamatkomaev/yet_another_calendar_backend:${YET_ANOTHER_CALENDAR_VERSION:-latest} restart: always volumes: - ./backend:/app/src/ - env_file: - backend/.env depends_on: redis: @@ -37,9 +36,8 @@ services: build: context: ./frontend target: dev-run - image: ghcr.io/azamatkomaev/yet_another_calendar_frontend:${YET_ANOTHER_CALENDAR_VERSION:-dev} + image: ghcr.io/azamatkomaev/yet_another_calendar_frontend:${YET_ANOTHER_CALENDAR_VERSION:-latest} container_name: calendar-frontend - env_file: - frontend/.env restart: always volumes: