Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/convert ci cd to the prod #553

Merged
merged 123 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 121 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
2c4b1d1
test prod workflow
OlegGsk Sep 23, 2024
0bfa42e
fix /infra/prod/
OlegGsk Sep 24, 2024
ff24d4e
fix docker compose prod
OlegGsk Sep 24, 2024
1cbcf94
test prod.dockerfile
OlegGsk Sep 24, 2024
9962a93
test prod.dockerfile2
OlegGsk Sep 24, 2024
f8d457c
test prod.dockerfile3
OlegGsk Sep 24, 2024
3d4ffa2
test prod.dockerfile4
OlegGsk Sep 24, 2024
a9abd9b
test prod.dockerfile5
OlegGsk Sep 24, 2024
698608b
test prod.dockerfile6
OlegGsk Sep 24, 2024
a3c6648
test deploy to production
OlegGsk Sep 24, 2024
f9fec85
test deploy to production2
OlegGsk Sep 24, 2024
f723f6d
test deploy to production3
OlegGsk Sep 24, 2024
440bf57
test deploy to production4
OlegGsk Sep 24, 2024
1930378
test deploy to production6
OlegGsk Sep 24, 2024
930453a
test deploy to production7
OlegGsk Sep 25, 2024
6c659eb
test deploy to production8
OlegGsk Sep 25, 2024
a74d380
test deploy to production9
OlegGsk Sep 25, 2024
d3df132
test deploy to production10
OlegGsk Sep 25, 2024
6f2c7f9
test deploy to production10
OlegGsk Sep 25, 2024
7b04894
test deploy to production11
OlegGsk Sep 25, 2024
d7c9c22
test deploy to production12
OlegGsk Sep 25, 2024
d2ce8b8
test deploy to production13
OlegGsk Sep 25, 2024
4512e64
test deploy to production14
OlegGsk Sep 25, 2024
27a3d35
test deploy to production15
OlegGsk Sep 25, 2024
916dbc9
test deploy to production16
OlegGsk Sep 25, 2024
b33a2f1
test deploy to production17
OlegGsk Sep 25, 2024
520d38a
test deploy to production18
OlegGsk Sep 25, 2024
d6022d4
test deploy to production19
OlegGsk Sep 25, 2024
b4d5f66
test deploy to production20
OlegGsk Sep 25, 2024
176154c
test deploy to production21
OlegGsk Sep 25, 2024
adf55b9
test deploy to production22
OlegGsk Sep 25, 2024
5c63d6d
test deploy to production23
OlegGsk Sep 25, 2024
193823f
test deploy to production24
OlegGsk Sep 26, 2024
54ae2ea
test deploy to production25
OlegGsk Sep 26, 2024
5362f84
test deploy to production26
OlegGsk Sep 26, 2024
29f9fbe
test deploy to production27
OlegGsk Sep 26, 2024
28ced68
test secrets
OlegGsk Sep 26, 2024
2f559ff
test secrets1
OlegGsk Sep 26, 2024
53be901
test secrets2
OlegGsk Sep 26, 2024
783d553
test secrets3
OlegGsk Sep 26, 2024
bffe6d7
test secrets4
OlegGsk Sep 26, 2024
0ad8682
test secrets5
OlegGsk Sep 26, 2024
53ae4e1
test secrets6
OlegGsk Sep 26, 2024
73ed84a
test secrets7
OlegGsk Sep 26, 2024
5c05913
test copy infra to vps
OlegGsk Sep 26, 2024
d4c7608
test copy infra to vps - 1
OlegGsk Sep 26, 2024
3bd7af3
test copy infra to vps - 2
OlegGsk Sep 26, 2024
f2d68f9
test copy infra to vps - 3
OlegGsk Sep 26, 2024
c878c46
test copy infra to vps - 4
OlegGsk Sep 26, 2024
3df804f
test copy infra to vps - 5
OlegGsk Sep 26, 2024
1a3d8d7
test copy infra to vps - 6
OlegGsk Sep 26, 2024
9403383
test copy infra to vps - 7
OlegGsk Sep 26, 2024
8f4b992
test copy infra to vps - 8
OlegGsk Sep 26, 2024
c33f385
test copy infra to vps - 9
OlegGsk Sep 26, 2024
a9d883d
test copy infra to vps - 10
OlegGsk Sep 26, 2024
c4e2321
test copy infra to vps - 11
OlegGsk Sep 26, 2024
58acbd1
test copy infra to vps - 12
OlegGsk Sep 26, 2024
e7f68c8
test deploy
OlegGsk Sep 27, 2024
695d6bd
test deploy1
OlegGsk Sep 27, 2024
807c7aa
test deploy2
OlegGsk Sep 27, 2024
aa4065f
test deploy3
OlegGsk Sep 27, 2024
891c452
test deploy4
OlegGsk Sep 27, 2024
c786a8e
test deploy5
OlegGsk Sep 27, 2024
846ba06
test deploy6
OlegGsk Sep 27, 2024
5110552
test deploy7
OlegGsk Sep 27, 2024
fedd3f2
test deploy8
OlegGsk Sep 27, 2024
7392223
test deploy8
OlegGsk Sep 27, 2024
d8bc2ef
test deploy9
OlegGsk Sep 27, 2024
0f3e7a1
test deploy10
OlegGsk Sep 27, 2024
5e421b8
test deploy11
OlegGsk Sep 27, 2024
36c394c
test deploy12
OlegGsk Sep 27, 2024
aab2f02
test deploy13
OlegGsk Sep 27, 2024
da36781
test deploy14
OlegGsk Sep 27, 2024
565f906
test deploy15
OlegGsk Sep 27, 2024
48ec311
test deploy16
OlegGsk Sep 27, 2024
4ddddd5
test deploy17
OlegGsk Sep 27, 2024
1ed0ca7
test deploy18
OlegGsk Sep 27, 2024
786827b
test deploy19
OlegGsk Sep 27, 2024
8c6827c
test deploy20
OlegGsk Sep 27, 2024
ecba4ae
test deploy21
OlegGsk Sep 27, 2024
28fce2a
pre-realease
OlegGsk Sep 27, 2024
456a6eb
pre-realease1
OlegGsk Sep 27, 2024
a0b3362
pre-realease2
OlegGsk Sep 27, 2024
1bc1efc
pre-realease3
OlegGsk Sep 28, 2024
9405720
pre-realease4
OlegGsk Sep 28, 2024
83a9f17
pre-realease5
OlegGsk Sep 28, 2024
fa2d1db
pre-realease6
OlegGsk Sep 28, 2024
c3f8f18
pre-realease7
OlegGsk Sep 28, 2024
df1e668
pre-realease8
OlegGsk Sep 28, 2024
d8cc99a
pre-realease9
OlegGsk Sep 28, 2024
875a0dd
pre-realease10
OlegGsk Sep 28, 2024
d2abf66
pre-realease11
OlegGsk Sep 28, 2024
4e6eb8b
on review
OlegGsk Sep 28, 2024
c87c5da
test build
OlegGsk Sep 28, 2024
cb568be
test build1
OlegGsk Sep 28, 2024
c04aff3
test build2
OlegGsk Sep 28, 2024
ad14fbd
test build3
OlegGsk Sep 28, 2024
3dd162a
test watchtower
OlegGsk Sep 28, 2024
808d7b1
test watchtower1
OlegGsk Sep 28, 2024
d466f03
on review3
OlegGsk Sep 28, 2024
251bde8
on review4
OlegGsk Sep 28, 2024
9a125d7
test build
OlegGsk Sep 29, 2024
0eb325c
test build1
OlegGsk Sep 29, 2024
114b9c9
on review 4
OlegGsk Sep 29, 2024
eac00c7
test build-1
OlegGsk Sep 29, 2024
a7562be
test build-2
OlegGsk Sep 29, 2024
9a7f6fe
test build 5
OlegGsk Sep 29, 2024
7015852
test build 6
OlegGsk Sep 29, 2024
f5b44b7
test build 6
OlegGsk Sep 29, 2024
ff13ebe
test build 7
OlegGsk Sep 29, 2024
090e16f
test build 8
OlegGsk Sep 29, 2024
a28a143
test build 8
OlegGsk Sep 30, 2024
ba30530
test build 9
OlegGsk Sep 30, 2024
40c6df2
test build 10
OlegGsk Sep 30, 2024
2a94235
test build 11
OlegGsk Sep 30, 2024
92f3e71
test build 12
OlegGsk Sep 30, 2024
84d79ad
test build 14
OlegGsk Sep 30, 2024
a941288
on_review
OlegGsk Sep 30, 2024
3122a24
on_review final
OlegGsk Oct 1, 2024
5f925c3
on_review final
OlegGsk Oct 1, 2024
6b390d3
on_review final1
OlegGsk Oct 1, 2024
ccaef8a
fix by review
OlegGsk Oct 1, 2024
9680c9c
Merge branch 'dev' into feature/convert_ci-cd_to_the_prod
OlegGsk Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]

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

This file was deleted.

133 changes: 133 additions & 0 deletions .github/workflows/prod_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
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: Copy infra via ssh
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут ты генерировал свой ключ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да генерировал пару ключей на сервере(но почему то ssh-keyscan не видит ключа открытого , хотя положил его в /home/production/.ssh/authorized_keys)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Их можно и у себя генерить. Просто приватный кладешь в секреты, а публичный в авторизованные

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
8 changes: 6 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI
name: Pytest

on: [pull_request]
on:
push:
branches:
- dev
- feature/*

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже наверно стоит убрать feature

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

минута

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

This file was deleted.

Loading
Loading