-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ffe01f
commit 697b7ec
Showing
2 changed files
with
120 additions
and
110 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,110 @@ | ||
# name: CI/CD for Kittygram | ||
|
||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
|
||
# jobs: | ||
# lint: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout Repository | ||
# uses: actions/checkout@v4 | ||
|
||
# - name: Set up Python | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: '3.10' | ||
|
||
# - name: Install dependencies | ||
# run: | | ||
# python -m pip install --upgrade pip | ||
# pip install flake8 | ||
|
||
# - name: Run PEP8 check | ||
# run: | | ||
# flake8 backend --count --max-complexity=10 --max-line-length=119 --show-source --statistics | ||
|
||
# test: | ||
# runs-on: ubuntu-latest | ||
# needs: lint | ||
# steps: | ||
# - name: Checkout Repository | ||
# uses: actions/checkout@v4 | ||
|
||
# - name: Set up Python | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: '3.10' | ||
|
||
# - name: Install backend dependencies | ||
# run: | | ||
# python -m pip install --upgrade pip | ||
# pip install -r backend/requirements.txt | ||
|
||
# - name: Run backend tests | ||
# run: | | ||
# pytest tests/ | ||
|
||
# - name: Run frontend tests | ||
# run: | | ||
# cd frontend && npm install && npm test | ||
|
||
# deploy: | ||
# runs-on: ubuntu-latest | ||
# needs: test | ||
# steps: | ||
# - name: Checkout Repository | ||
# uses: actions/checkout@v4 | ||
|
||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v2 | ||
|
||
# - name: Log in to DockerHub | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# - name: Build and push backend image | ||
# run: | | ||
# docker build -t ${{ secrets.DOCKER_USERNAME }}/kittygram_backend:latest ./backend | ||
# docker push ${{ secrets.DOCKER_USERNAME }}/kittygram_backend:latest | ||
|
||
# - name: Build and push frontend image | ||
# run: | | ||
# docker build -t ${{ secrets.DOCKER_USERNAME }}/kittygram_frontend:latest ./frontend | ||
# docker push ${{ secrets.DOCKER_USERNAME }}/kittygram_frontend:latest | ||
|
||
# - name: Build and push gateway image | ||
# run: | | ||
# docker build -t ${{ secrets.DOCKER_USERNAME }}/kittygram_gateway:latest ./nginx | ||
# docker push ${{ secrets.DOCKER_USERNAME }}/kittygram_gateway:latest | ||
|
||
# - name: Deploy to Server | ||
# uses: appleboy/ssh-action@v1.0.3 | ||
# with: | ||
# host: ${{ secrets.SSH_HOST }} | ||
# username: ${{ secrets.SSH_USER }} | ||
# key: ${{ secrets.SSH_KEY }} | ||
# script: | | ||
# cd ~/kittygram | ||
# docker pull ${{ secrets.DOCKER_USERNAME }}/kittygram_backend:latest | ||
# docker pull ${{ secrets.DOCKER_USERNAME }}/kittygram_frontend:latest | ||
# docker pull ${{ secrets.DOCKER_USERNAME }}/kittygram_gateway:latest | ||
# docker-compose -f docker-compose.production.yml down | ||
# docker-compose -f docker-compose.production.yml up -d | ||
# docker exec backend python manage.py migrate | ||
# docker exec backend python manage.py collectstatic --noinput | ||
# docker restart gateway | ||
|
||
# notify: | ||
# runs-on: ubuntu-latest | ||
# needs: deploy | ||
# steps: | ||
# - name: Send Telegram Notification | ||
# run: | | ||
# curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \ | ||
# -d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \ | ||
# -d "text=🎉 Kittygram успешно задеплоен!" | ||
name: CI/CD for Kittygram | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Run PEP8 check | ||
run: | | ||
flake8 backend --count --max-complexity=10 --max-line-length=119 --show-source --statistics | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: lint | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install backend dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r backend/requirements.txt | ||
- name: Run backend tests | ||
run: | | ||
pytest tests/ | ||
- name: Run frontend tests | ||
run: | | ||
cd frontend && npm install && npm test | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push backend image | ||
run: | | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/kittygram_backend:latest ./backend | ||
docker push ${{ secrets.DOCKER_USERNAME }}/kittygram_backend:latest | ||
- name: Build and push frontend image | ||
run: | | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/kittygram_frontend:latest ./frontend | ||
docker push ${{ secrets.DOCKER_USERNAME }}/kittygram_frontend:latest | ||
- name: Build and push gateway image | ||
run: | | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/kittygram_gateway:latest ./nginx | ||
docker push ${{ secrets.DOCKER_USERNAME }}/kittygram_gateway:latest | ||
- name: Deploy to Server | ||
uses: appleboy/ssh-action@v1.0.3 | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_KEY }} | ||
script: | | ||
cd ~/kittygram | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/kittygram_backend:latest | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/kittygram_frontend:latest | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/kittygram_gateway:latest | ||
docker-compose -f docker-compose.production.yml down | ||
docker-compose -f docker-compose.production.yml up -d | ||
docker exec backend python manage.py migrate | ||
docker exec backend python manage.py collectstatic --noinput | ||
docker restart gateway | ||
notify: | ||
runs-on: ubuntu-latest | ||
needs: deploy | ||
steps: | ||
- name: Send Telegram Notification | ||
run: | | ||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \ | ||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \ | ||
-d "text=🎉 Kittygram успешно задеплоен!" |
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