ci: Added CD to repo CI
This commit is contained in:
1 parent
b8422f5472
commit
15ced43fe4
2 files changed
+37
-1
No files matched your search
@@ -28,7 +28,7 @@ jobs:
|
|||||||
id: tags
|
id: tags
|
||||||
uses: https://github.com/cssnr/docker-tags-action@v2
|
uses: https://github.com/cssnr/docker-tags-action@v2
|
||||||
with:
|
with:
|
||||||
images: 'git.rustprogersteam.ru/pvhproject/pvhfrontend/'
|
images: 'git.rustprogersteam.ru/pvhproject/pvhbackend/'
|
||||||
|
|
||||||
- name: Login to Docker Registry
|
- name: Login to Docker Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -51,3 +51,24 @@ jobs:
|
|||||||
labels: ${{ steps.tags.outputs.labels }}
|
labels: ${{ steps.tags.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: docker-build-and-push
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Ansible
|
||||||
|
run: apt-get update && apt-get install -y ansible
|
||||||
|
- name: Set up SSH key
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
- name: Trust server host key
|
||||||
|
run: |
|
||||||
|
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||||
|
- name: Run Ansible playbook
|
||||||
|
run: |
|
||||||
|
ansible-playbook -i "${{ secrets.SERVER_IP }}," ansible/restart_compose.yml \
|
||||||
|
--user "${{ secrets.SERVER_USER }}" \
|
||||||
|
--private-key ~/.ssh/deploy_key
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
- name: Restart Docker Compose services
|
||||||
|
hosts: all
|
||||||
|
# become: yes # <-- больше не нужно, т.к. пользователь уже имеет права Docker
|
||||||
|
tasks:
|
||||||
|
- name: docker compose down
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: docker compose down
|
||||||
|
chdir: /etc/compose/pvh
|
||||||
|
- name: prune system
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: docker system prune -a -f
|
||||||
|
- name: docker compose up -d
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: docker compose up -d
|
||||||
|
chdir: /etc/compose/pvh
|
||||||
Reference in new issue
Block a user