-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (99 loc) · 4.9 KB
/
deploy.yml
File metadata and controls
113 lines (99 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Deploy to NexusHosting
on:
push:
branches:
- main
paths:
- "dist/**"
- "public/**"
- "out/**"
- "build/**"
- ".github/workflows/deploy.yml"
workflow_dispatch:
inputs:
site_id:
description: "NexusHosting site ID to deploy to"
required: true
type: string
dir:
description: "Directory to deploy (default: dist)"
required: false
default: "dist"
# ──────────────────────────────────────────────────────────────────────────────
# Required repository secrets:
# FH_TOKEN — API token from NexusHosting (My Sites → API Tokens → New Token)
# FH_NODE_URL — URL of your NexusHosting node (e.g. https://node.example.com)
# FH_SITE_ID — Numeric site ID from NexusHosting
#
# Optional:
# FH_DEPLOY_DIR — Directory to deploy (default: dist)
# ──────────────────────────────────────────────────────────────────────────────
env:
FH_NODE_URL: ${{ secrets.FH_NODE_URL }}
FH_TOKEN: ${{ secrets.FH_TOKEN }}
FH_SITE_ID: ${{ inputs.site_id || secrets.FH_SITE_ID }}
FH_DEPLOY_DIR: ${{ inputs.dir || vars.FH_DEPLOY_DIR || 'dist' }}
jobs:
deploy:
name: Deploy to NexusHosting
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
# ── Optional: build step ─────────────────────────────────────────────
# Uncomment the block that matches your project's build toolchain.
# Delete everything in this section if you push pre-built files.
# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: npm # or: pnpm / yarn
# - name: Install dependencies
# run: npm ci # or: pnpm install --frozen-lockfile
# - name: Build
# run: npm run build # adjust to your build command
# ── Verify the deploy directory exists ──────────────────────────────
- name: Verify deploy directory
run: |
if [ ! -d "$FH_DEPLOY_DIR" ]; then
echo "::error::Deploy directory '$FH_DEPLOY_DIR' does not exist."
echo "::error::Make sure your build step outputs files there, or set FH_DEPLOY_DIR."
exit 1
fi
FILE_COUNT=$(find "$FH_DEPLOY_DIR" -type f | wc -l)
echo "Found $FILE_COUNT file(s) in $FH_DEPLOY_DIR"
if [ "$FILE_COUNT" -eq 0 ]; then
echo "::error::No files found in '$FH_DEPLOY_DIR'. Nothing to deploy."
exit 1
fi
# ── Install the fh CLI ───────────────────────────────────────────────
- name: Install NexusHosting CLI
run: npm install -g @nexushosting/cli 2>/dev/null || npx --yes @nexushosting/cli --version || true
# Fall back to running from source if not yet on npm
# TODO: replace with: npm install -g @nexushosting/cli once published
# ── Authenticate ─────────────────────────────────────────────────────
- name: Authenticate with NexusHosting node
run: |
nh login \
--node "$FH_NODE_URL" \
--token "$FH_TOKEN"
# ── Deploy ───────────────────────────────────────────────────────────
- name: Deploy site
id: deploy
run: |
nh deploy "$FH_DEPLOY_DIR" \
--site "$FH_SITE_ID" \
--concurrency 6
# ── Summary ──────────────────────────────────────────────────────────
- name: Deployment summary
if: success()
run: |
echo "## ✅ Deployed to NexusHosting" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Node | \`$FH_NODE_URL\` |" >> $GITHUB_STEP_SUMMARY
echo "| Site ID | \`$FH_SITE_ID\` |" >> $GITHUB_STEP_SUMMARY
echo "| Directory | \`$FH_DEPLOY_DIR\` |" >> $GITHUB_STEP_SUMMARY
echo "| Commit | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY