Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
push:
branches-ignore: [main]

# Minimal read-only permissions — no write access needed for CI validation
permissions:
contents: read

jobs:
validate:
name: Validate
Expand Down
43 changes: 19 additions & 24 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ name: Deploy
on:
push:
branches: [main]
# workflow_dispatch has no inputs — build output must not be affected by
# user-supplied parameters (SLSA provenance / supply-chain security requirement)
workflow_dispatch:
inputs:
mode:
description: 'Deploy mode'
required: false
default: 'normal'
type: choice
options:
- normal # Full deploy with all checks
- fast # Skip non-critical checks (syntax + test always run)
- dry-run # Simulate everything; do NOT sync files or restart service
- safe # Deploy but pause and require manual Telegram approval

# Minimal permissions — deploy job needs no write access to repo contents
permissions:
contents: read

# ──────────────────────────────────────────────────────────────────────────────
# Non-sensitive values (hard-coded per spec)
Expand All @@ -43,7 +38,7 @@ env:
RW_DISCORD_JOIN: "https://discord.gg/runewagers"
RW_DISCORD_LINK: "https://discord.com/channels/1100486422395355197/1249181934811349052"
RW_DISCORD_SUPPORT: "https://discord.com/channels/1100486422395355197/1249182067296567338"
DEPLOY_MODE: ${{ github.event.inputs.mode || 'normal' }}
DEPLOY_MODE: normal

jobs:
# ────────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -85,10 +80,10 @@ jobs:
- name: Run tests
run: npm test

# Gate 3: Security audit (non-blocking in fast mode)
# Gate 3: Security audit (always non-blocking — advisories warn, never block deploy)
- name: Security audit
run: npm audit --audit-level=high
continue-on-error: ${{ env.DEPLOY_MODE == 'fast' }}
continue-on-error: true

# Gate 4: Pre-deploy checks (skipped in fast mode)
- name: Pre-deploy checks
Expand Down Expand Up @@ -226,24 +221,24 @@ jobs:
.env \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/var/www/html/Runewager/current/.env

# ── Run smoke test on VPS ─────────────────────────────────────────────────
- name: Smoke test on VPS
id: smoke
# ── npm ci on VPS ─────────────────────────────────────────────────────────
- name: Install dependencies on VPS
run: |
ssh deploy_target "
set -euo pipefail
DEPLOY_DIR=/var/www/html/Runewager/current
chmod +x \$DEPLOY_DIR/scripts/smoke-test.sh
\$DEPLOY_DIR/scripts/smoke-test.sh \$DEPLOY_DIR
cd /var/www/html/Runewager/current
npm ci --omit=dev
"

# ── npm ci on VPS ─────────────────────────────────────────────────────────
- name: Install dependencies on VPS
# ── Run smoke test on VPS (after deps installed) ──────────────────────────
- name: Smoke test on VPS
id: smoke
run: |
ssh deploy_target "
set -euo pipefail
cd /var/www/html/Runewager/current
npm ci --omit=dev
DEPLOY_DIR=/var/www/html/Runewager/current
chmod +x \$DEPLOY_DIR/scripts/smoke-test.sh
\$DEPLOY_DIR/scripts/smoke-test.sh \$DEPLOY_DIR
"

# ── Verify .env on VPS ─────────────────────────────────────────────────────
Expand Down
Loading