Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve conflicts
Browse files Browse the repository at this point in the history
KonstantinRaikhert committed Oct 8, 2024
2 parents 6e20c00 + 2f6bee4 commit d064033
Showing 60 changed files with 568 additions and 3,685 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ codestyle_pep8.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Codestyle_pep8

on: [push, pull_request]

51 changes: 0 additions & 51 deletions .github/workflows/build-and-push-github-packages.yaml

This file was deleted.

147 changes: 147 additions & 0 deletions .github/workflows/prod_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Production deploy

on:
push:
branches:
- master
env:
DEPLOY_PATH: adaptive_hockey_federation
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

defaults:
run:
working-directory: .

jobs:
pytest:
runs-on: ubuntu-latest
name: pytest
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Poetry
uses: snok/install-poetry@v1
with:
poetry-version: 1.5.0

- name: Check out the repo
uses: actions/checkout@v4

- name: Install dependencies
run: |
poetry install
- name: pytest
run: |
poetry run pytest
working-directory: adaptive_hockey_federation

build_and_push:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: pytest

steps:
- uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image for Production
uses: docker/build-push-action@v5
with:
context: .
file: infra/prod/prod.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


deploy:
if: github.ref == 'refs/heads/master'
name: Deploy changes on server
needs: [pytest, build_and_push]
runs-on: ubuntu-latest
environment:
name: prod_deploy
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Delete stage & dev
run: |
rm -r infra/stage
rm -r infra/dev
- name: Stopping old containers
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
STATUS="$(systemctl is-active adaptive_hockey_federation.service)"
if [ "${STATUS}" = "active" ]; then
sudo systemctl stop adaptive_hockey_federation.service
echo "Stopping old containers"
else
echo "No active containers"
fi
- name: Copy infra via ssh
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
source: "infra/"
target: "${{ env.DEPLOY_PATH }}/infra"
rm: true
strip_components: 1
- name: Execute commands on VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ${{ env.DEPLOY_PATH }}
touch .env
echo "${{ secrets.ENV_FILE }}" > .env
cd infra/prod/
sudo systemctl stop adaptive_hockey_federation.service
docker system prune --force
sudo cp -f /home/production/adaptive_hockey_federation/infra/prod/adaptive_hockey_federation.service /etc/systemd/system/adaptive_hockey_federation.service
sudo systemctl daemon-reload
sudo systemctl start adaptive_hockey_federation.service
sudo systemctl is-active --quiet adaptive_hockey_federation.service
until [ $? -eq 0 ]; do
echo "Waiting for adaptive_hockey_federation.service to be active..."
sleep 5
sudo systemctl is-active --quiet adaptive_hockey_federation.service
done
echo "adaptive_hockey_federation.service is active"
docker exec adaptive_hockey_federation python manage.py collectstatic --noinput
docker exec adaptive_hockey_federation python manage.py migrate
7 changes: 5 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: CI
name: Pytest

on: [pull_request]
on:
push:
branches:
- dev

jobs:
pytest:
129 changes: 0 additions & 129 deletions .github/workflows/stage_deploy.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -184,3 +184,5 @@ media/
# DS server
a_hockey-main/
adaptive_hockey_federation/service/test_video/

db_dump.json
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-docstring-first
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
rev: v0.6.8
hooks:
- id: ruff
exclude: migrations/|config/|tests/|.*settings(\.py|/)?
2 changes: 0 additions & 2 deletions adaptive_hockey_federation/core/config/base_settings.py
Original file line number Diff line number Diff line change
@@ -40,8 +40,6 @@
"competitions.apps.CompetitionsConfig",
"analytics.apps.AnalyticsConfig",
"unloads.apps.UnloadsConfig",
"games.apps.GamesConfig",
"video_api.apps.VideoApiConfig",
]

INSTALLED_APPS = EXTERNAL_APPS + DEFAULT_APPS + LOCAL_APPS
Loading

0 comments on commit d064033

Please sign in to comment.