Initial commit
CI / Сборка (push) Canceled after 0s
CI / Деплой на стейджинг (push) Canceled after 0s
CI / Проверка кода (push) Canceled after 0s
CI / Сборка (pull_request) Successful in 1m33s
Стенд master
CI / Деплой на стейджинг (pull_request) Successful in 8s
CI / Проверка кода (pull_request) Successful in 1m32s

This commit is contained in:
arswarog committed 2026-11-10 17:22:12 +03:00
commit 1420aad1ae
92 files changed
+19114

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
name: Cleanup
on:
delete:
pull_request:
types: [closed]
workflow_dispatch:
concurrency:
group: cleanup-${{ github.event.pull_request.head.ref || github.event.ref || github.ref_name }}
jobs:
cleanup:
name: Удаление стенда
runs-on: ubuntu-latest
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'delete' && github.event.ref_type == 'branch') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository)
steps:
- name: Удаление стенда
uses: jt4d-lab/ssh-action@v1
with:
host: ${{ vars.STAGING_HOST }}
username: ${{ vars.STAGING_USER }}
key: ${{ secrets.STAGING_SSH_PRIVATE_KEY }}
port: ${{ vars.STAGING_PORT }}
script_stop: true
script: |
BRANCH_NAME="${{ github.event.ref || github.event.pull_request.head.ref || github.ref_name }}"
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
DEPLOY_DIR="/home/${{ vars.STAGING_USER }}/${{ github.event.repository.name }}_${BRANCH_NAME}"
echo "Deleting stand for branch: ${BRANCH_NAME}"
echo $DEPLOY_DIR
# Стек гасим до удаления базы: DROP DATABASE не пройдёт при живом подключении api.
if [ -d "$DEPLOY_DIR" ]; then
cd "$DEPLOY_DIR"
docker compose down --rmi all || true
fi
staging-db-postgres delete "${{ github.repository }}" "$BRANCH_NAME"
cd "$HOME"
rm -rf "$DEPLOY_DIR"
docker system prune -f
- name: Удаление docker образов
run: |
BRANCH_NAME="${{ github.event.ref || github.event.pull_request.head.ref || github.ref_name }}"
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
OWNER="${{ github.repository_owner }}"
REPO_NAME="${{ github.event.repository.name }}"
SERVER="${{ github.server_url }}"
for IMAGE in web api; do
PACKAGE="${REPO_NAME}%2F${IMAGE}"
URL="${SERVER}/api/v1/packages/${OWNER}/container/${PACKAGE}/${BRANCH_NAME}"
echo "Deleting ${URL}"
curl -i -sS \
-X DELETE \
-H "Authorization: token ${{ secrets.SERVICE_BOT_TOKEN }}" \
"${URL}" || true
echo
done