Compare commits

...

2 Commits

Author SHA1 Message Date
peptiderepo
c5f4149698 fix(ci): ssh-keyscan failure no longer fails the deploy
ssh-keyscan was being called with set -e in effect and stderr suppressed,
so a single keyscan failure killed the entire deploy with no diagnostic
output. Since rsync/ssh use StrictHostKeyChecking=no, the known_hosts
entry is not load-bearing — making the keyscan best-effort is safe.
stderr is now captured to /tmp/keyscan.err and emitted as a warning so
future failures are debuggable.

Agent-Session: cowork-deploy-fix-20260414
2026-04-14 16:53:01 +07:00
peptiderepo
1741720110 ci: post CTO review as COMMENT instead of APPROVE
GITHUB_TOKEN cannot formally approve PRs without a repo setting toggle.
Verdict is still prominent in the first line of the review body, and
the human merges based on reading it — no behavior loss.

Agent-Session: cowork-reviewer-fix-20260414
2026-04-14 16:52:07 +07:00
2 changed files with 100 additions and 98 deletions

View File

@@ -224,25 +224,22 @@ jobs:
PY PY
- name: Post PR review - name: Post PR review
# Always posts as COMMENT — not APPROVE/REQUEST_CHANGES — because the default
# GITHUB_TOKEN is not permitted to formally approve PRs without toggling a
# repo setting. The verdict is still prominent in the first line of the body
# ("## CTO Review — APPROVE|REQUEST_CHANGES|COMMENT"). Human merges, so the
# GitHub-native review state isn't load-bearing.
if: steps.claude.outputs.skipped != '1' if: steps.claude.outputs.skipped != '1'
uses: actions/github-script@v7 uses: actions/github-script@v7
env:
VERDICT: ${{ steps.claude.outputs.verdict }}
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
const body = fs.readFileSync('/tmp/review-body.md', 'utf8'); const body = fs.readFileSync('/tmp/review-body.md', 'utf8');
const verdict = process.env.VERDICT;
const eventMap = {
'APPROVE': 'APPROVE',
'REQUEST_CHANGES': 'REQUEST_CHANGES',
'COMMENT': 'COMMENT'
};
await github.rest.pulls.createReview({ await github.rest.pulls.createReview({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: context.issue.number, pull_number: context.issue.number,
event: eventMap[verdict] || 'COMMENT', event: 'COMMENT',
body, body,
}); });

View File

@@ -1,90 +1,95 @@
name: Deploy Theme to Hostinger name: Deploy Theme to Hostinger
on: on:
push: push:
branches: [main] branches: [main]
jobs: jobs:
validate: validate:
name: Validate PHP & JS name: Validate PHP & JS
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: PHP Lint Check - name: PHP Lint Check
run: | run: |
find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; | (grep -v "No syntax errors" || true) | head -20 find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; | (grep -v "No syntax errors" || true) | head -20
test ${PIPESTATUS[0]} -eq 0 test ${PIPESTATUS[0]} -eq 0
- name: Install PHPCS with WordPress standards - name: Install PHPCS with WordPress standards
run: | run: |
composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer global require --dev squizlabs/php_codesniffer:"^3.0" wp-coding-standards/wpcs:"^3.0" phpcsstandards/phpcsutils:"^1.0" composer global require --dev squizlabs/php_codesniffer:"^3.0" wp-coding-standards/wpcs:"^3.0" phpcsstandards/phpcsutils:"^1.0"
- name: Run PHPCS (WordPress Core) - name: Run PHPCS (WordPress Core)
run: | run: |
~/.composer/vendor/bin/phpcs -s . ~/.composer/vendor/bin/phpcs -s .
- name: JS Syntax Check - name: JS Syntax Check
run: | run: |
find assets/js -name "*.js" -exec node --check {} \; find assets/js -name "*.js" -exec node --check {} \;
deploy: deploy:
needs: validate needs: validate
name: Deploy to Production name: Deploy to Production
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup SSH key - name: Setup SSH key
run: | run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts 2>/dev/null # Best-effort: keyscan stderr captured for diagnosis but never fatal.
# We use StrictHostKeyChecking=no on the actual ssh/rsync calls anyway.
- name: Deploy via rsync ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts 2>/tmp/keyscan.err || {
run: | echo "::warning::ssh-keyscan failed (non-fatal). stderr:"
rsync -avz --delete \ cat /tmp/keyscan.err || true
--exclude='.git' \ }
--exclude='.github' \
--exclude='tests/' \ - name: Deploy via rsync
--exclude='phpunit.xml' \ run: |
--exclude='composer.json' \ rsync -avz --delete \
--exclude='composer.lock' \ --exclude='.git' \
--exclude='vendor/' \ --exclude='.github' \
--exclude='node_modules/' \ --exclude='tests/' \
--exclude='.phpcs.xml.dist' \ --exclude='phpunit.xml' \
-e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no" \ --exclude='composer.json' \
./ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/themes/peptide-starter/ --exclude='composer.lock' \
--exclude='vendor/' \
- name: Purge LiteSpeed Cache --exclude='node_modules/' \
run: | --exclude='.phpcs.xml.dist' \
ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no \ -e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no" \
${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'ENDSSH' ./ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/themes/peptide-starter/
CACHE_DIR="/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/litespeed"
if [ -d "$CACHE_DIR" ]; then - name: Purge LiteSpeed Cache
rm -rf "$CACHE_DIR"/* run: |
echo "LiteSpeed cache purged." ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no \
fi ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'ENDSSH'
touch "/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/.lscache_purge" 2>/dev/null || true CACHE_DIR="/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/litespeed"
echo "Cache purge signal sent." if [ -d "$CACHE_DIR" ]; then
ENDSSH rm -rf "$CACHE_DIR"/*
echo "LiteSpeed cache purged."
- name: Cleanup fi
if: always() touch "/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/.lscache_purge" 2>/dev/null || true
run: rm -f ~/.ssh/deploy_key echo "Cache purge signal sent."
ENDSSH
- name: Health check
run: | - name: Cleanup
sleep 5 if: always()
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://peptiderepo.com) run: rm -f ~/.ssh/deploy_key
if [ "$STATUS" != "200" ]; then
echo "WARNING: Site returned HTTP $STATUS after deploy" - name: Health check
exit 1 run: |
fi sleep 5
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://peptiderepo.com)
if [ "$STATUS" != "200" ]; then
echo "WARNING: Site returned HTTP $STATUS after deploy"
exit 1
fi
echo "Site is healthy (HTTP 200)" echo "Site is healthy (HTTP 200)"