-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (120 loc) · 5.21 KB
/
Copy pathbuild.yml
File metadata and controls
141 lines (120 loc) · 5.21 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Build & Package
on:
push:
branches: ['**']
pull_request:
branches: [main, dev]
permissions:
contents: read
id-token: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.node-version'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Create deploy tarball
run: |
# Package source + .next build (no node_modules — installed on target)
tar czf /tmp/sleepypod-core.tar.gz \
--exclude='node_modules' \
--exclude='.git' \
--exclude='.env*' \
--exclude='*.db' \
--exclude='*.db-*' \
--exclude='test-results' \
--exclude='.serena' \
--exclude='.claude' \
.
mv /tmp/sleepypod-core.tar.gz .
- name: Upload artifact
id: upload
uses: actions/upload-artifact@v7
with:
name: sleepypod-core
path: sleepypod-core.tar.gz
retention-days: 30
- name: Inject install commands into PR description
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
RUN_ID: ${{ github.run_id }}
REPO: ${{ github.repository }}
SERVER: ${{ github.server_url }}
ARTIFACT_URL: ${{ steps.upload.outputs.artifact-url }}
run: |
set -euo pipefail
SHORT_SHA="${HEAD_SHA:0:7}"
cat > /tmp/section.md <<EOF
<!-- sleepypod:install-start -->
<!-- 🛑 AUTO-GENERATED — sleepypod-bot owns this block.
Hello fellow agent / curious human! Anything between the
sleepypod:install-start and sleepypod:install-end markers
gets overwritten on the next CI run. Want to change what's
here? Edit .github/workflows/build.yml instead. 💤 -->
<details open>
<summary>🛏️ <strong>Beam this PR onto a sleepypod</strong> ✨</summary>
Pick the snippet that matches your pod. **Already-installed pods can't use the curl bootstraps below** — sleepypod's egress firewall DROPs github.com, and the script that knows how to unblock WAN is the very file curl is trying to fetch. Use \`sp-update\` instead; it's on disk and opens WAN as its first step.
🔄 **Already on a sleepypod** (most common — review a PR on a running pod):
\`\`\`bash
sudo sp-update $HEAD_REF
\`\`\`
🚀 **Fresh pod / first install** — bootstraps from GitHub, rebuilds every push:
\`\`\`bash
curl -fsSL https://raw.githubusercontent.com/$REPO/$HEAD_REF/scripts/install \\
| sudo bash -s -- --branch $HEAD_REF
\`\`\`
🎯 **Pin to this exact build** ([run $RUN_ID]($SERVER/$REPO/actions/runs/$RUN_ID) · \`$SHORT_SHA\`) — fresh-pod path, locked to one CI artifact for reproducible review:
\`\`\`bash
curl -fsSL https://raw.githubusercontent.com/$REPO/$HEAD_SHA/scripts/install \\
| sudo bash -s -- \\
--branch $HEAD_REF \\
--artifact-url 'https://nightly.link/$REPO/actions/runs/$RUN_ID/sleepypod-core.zip'
\`\`\`
🧊 Artifact: [\`sleepypod-core\`]($ARTIFACT_URL) · self-destructs in 30 days 💥
</details>
<!-- sleepypod:install-end -->
EOF
# Fetch current body (jq's // "" handles null bodies).
gh pr view "$PR_NUMBER" --json body --jq '.body // ""' > /tmp/body.md
# Replace the marked section if it exists; otherwise append.
# Markers must sit at column 0 — anchoring with ^ stops the regex
# from matching when someone references the marker tokens inside
# backticks or prose in their PR description.
python3 - <<'PY'
import pathlib, re
body = pathlib.Path('/tmp/body.md').read_text()
section = pathlib.Path('/tmp/section.md').read_text().rstrip() + '\n'
pattern = re.compile(
r'^<!-- sleepypod:install-start -->.*?^<!-- sleepypod:install-end -->\n?',
re.DOTALL | re.MULTILINE,
)
if pattern.search(body):
new_body = pattern.sub(section, body)
else:
sep = '\n\n' if body.strip() else ''
new_body = body.rstrip() + sep + section
pathlib.Path('/tmp/new-body.md').write_text(new_body)
PY
# Only push an edit when the body actually changed.
if ! cmp -s /tmp/body.md /tmp/new-body.md; then
gh pr edit "$PR_NUMBER" --body-file /tmp/new-body.md
echo "PR description updated."
else
echo "PR description already current — no edit needed."
fi