ci: workflow по стандартному шаблону Gitea Actions
All checks were successful
deploy / deploy (push) Successful in 46s

Workflow приведён к шаблону из memory/reference_gitea_actions.md:
- runs-on: ubuntu-latest (act_runner на str-u-01 даёт node:20-bookworm)
- apt-get install openssh-client (нет в node:20 by default)
- secrets: SSH_DEPLOY_KEY (raw private key, не base64) + SSH_KNOWN_HOSTS
- ssh ... bash -s <<'REMOTE' с git clone/pull, docker compose build+up,
  health-check curl, docker image prune retention 7d
This commit is contained in:
2026-05-21 02:53:52 +03:00
parent 7f85f34b6a
commit 8cab51d590

View File

@@ -1,4 +1,4 @@
name: Deploy to web.hhivp.com name: deploy
on: on:
push: push:
@@ -9,34 +9,42 @@ jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up SSH key - name: Install SSH client
run: | run: |
mkdir -p ~/.ssh apt-get update -qq
echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > ~/.ssh/deploy_key apt-get install -y --no-install-recommends openssh-client
chmod 600 ~/.ssh/deploy_key
cat >> ~/.ssh/config <<EOF
Host web
HostName ${{ secrets.SSH_HOST }}
User ${{ secrets.SSH_USER }}
Port ${{ secrets.SSH_PORT }}
IdentityFile ~/.ssh/deploy_key
StrictHostKeyChecking accept-new
UserKnownHostsFile ~/.ssh/known_hosts
EOF
- name: Deploy - name: Setup SSH
run: | run: |
ssh web 'bash -s' <<'REMOTE' mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "${{ secrets.SSH_DEPLOY_KEY }}" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
printf '%s\n' "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Deploy to web.hhivp.com
run: |
ssh -i ~/.ssh/id_deploy striker@web.hhivp.com bash -s <<'REMOTE'
set -euo pipefail set -euo pipefail
cd /opt/docker/sites/anotherreflections-ru-v2 REPO_URL="ssh://git@git.striker.su:2222/striker/anotherreflections-website-v2.git"
git fetch --prune origin DEPLOY_PATH="/opt/docker/sites/anotherreflections-ru-v2"
HEALTH_URL="http://127.0.0.1:4084/"
if [ ! -d "$DEPLOY_PATH/.git" ]; then
mkdir -p "$DEPLOY_PATH"
git clone --branch main "$REPO_URL" "$DEPLOY_PATH"
else
cd "$DEPLOY_PATH"
git remote set-url origin "$REPO_URL"
git fetch origin main
git reset --hard origin/main git reset --hard origin/main
docker compose build --pull fi
cd "$DEPLOY_PATH"
docker compose build
docker compose up -d docker compose up -d
# Чистка старых образов (CI/CD retention >7d по правилу проекта) sleep 5
docker compose ps
curl -fsS -o /dev/null -w "HEALTH HTTP %{http_code}\n" "$HEALTH_URL"
docker image prune -af --filter "until=168h" >/dev/null 2>&1 || true docker image prune -af --filter "until=168h" >/dev/null 2>&1 || true
REMOTE REMOTE
- name: Verify
run: |
ssh web 'curl -sf -H "Host: anotherreflections.ru" http://127.0.0.1:4084/ -o /dev/null -w "HTTP %{http_code} | %{size_download} bytes\n"'