Skip to content

Commit

Permalink
ci/cd: Added GitHub Action for auto-deploy on push to main.
Browse files Browse the repository at this point in the history
  • Loading branch information
hazadus committed Jan 6, 2024
1 parent 33d109a commit 2962bb9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Continuous Integration

on:
push:
branches:
- main

concurrency:
group: main
cancel-in-progress: true

jobs:
qa:
name: Django Tests
uses: ./.github/workflows/django_tests.yml

deploy:
name: Deploy
needs: qa
runs-on: ubuntu-latest
steps:
- name: Configure SSH
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/github
chmod 600 ~/.ssh/github
cat >>~/.ssh/config <<END
Host target
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/github
LogLevel ERROR
StrictHostKeyChecking no
END
- name: Run Deploy
run: |
ssh target "cd /root/drf-nuxt-library && docker compose down && docker system prune -f -a --volumes && git pull && docker compose up -d --build --force-recreate"
2 changes: 1 addition & 1 deletion .github/workflows/django_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://www.hacksoft.io/blog/github-actions-in-action-setting-up-django-and-postgres
name: Django Tests

on: [push]
on: [pull_request, workflow_call]

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 06.01.2024, Сб
- 16:32 - CI/CD: добавлен GitHub Action для автоматического деплоя проекта при push в main.

## 10.07.2023, Пн

- 11:45 - Frontend: обновлены ссылки "Читать"/"Открыть в админке" на странице детального вида книги (теперь со значками и рядом).
Expand Down

0 comments on commit 2962bb9

Please sign in to comment.