-
Notifications
You must be signed in to change notification settings - Fork 4
114 lines (111 loc) · 3.83 KB
/
ci.yml
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
name: ci 🚀
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: checkout code 📥
- name: install pnpm 📦
uses: pnpm/action-setup@v4
with:
version: 9.5.0
- name: setup node 🟢
uses: actions/setup-node@v4
with:
node-version: "20.10.0"
cache: "pnpm"
- name: install dependencies 🔧
run: pnpm install
- name: run check ✅
run: pnpm check
env:
SMTP_HOST: localhost
SMTP_USER: test
SMTP_PASS: test
CF_TURNSTILE_SECRET: test
CF_TURNSTILE_SITEKEY: test
ADMIN_PASSWORD: test
DB_URL: ":memory:"
- name: create-plainweb local 🪨
run: ./create-plainweb/dist/cli.js my-plainweb-project --yes --no-git-init --debug --no-install
env:
npm_config_user_agent: ${{ github.actor }}
- name: ensure uses local plainweb (not npm)
run: |
echo " - \"my-plainweb-project\"" >> pnpm-workspace.yaml
sed -i 's/"plainweb": "[^"]*"/"plainweb": "workspace:*"/' my-plainweb-project/package.json
- name: install my-plainweb-project dependencies 🔧
run: |
cd my-plainweb-project
pnpm install --frozen-lockfile=false
- name: run build, test, and check on my-plainweb-project 🚀
run: |
cd my-plainweb-project
pnpm build
pnpm test
pnpm check
pnpm routes
- name: test server for my-plainweb-project 🌐
run: |
cd my-plainweb-project
pnpm serve &
sleep 5 # Wait for the server to start
if curl -s http://localhost:3000 | grep -q "Let's go"; then
echo "Server started successfully and contains 'Let's go'"
else
echo "Server check failed"
exit 1
fi
kill $! # Stop the server
rm -rf node_modules
create-plainweb:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: install pnpm 📦
uses: pnpm/action-setup@v4
with:
version: 9.5.0
- name: create-plainweb 🪨
run: |
pnpm dlx create-plainweb@latest my-plainweb-project --yes --no-git-init --debug
env:
npm_config_user_agent: ${{ github.actor }}
- name: run build, test, and check 🚀
run: |
cd my-plainweb-project
pnpm build
pnpm test
pnpm check
pnpm routes
- name: test server 🌐
run: |
cd my-plainweb-project
pnpm serve &
sleep 5 # Wait for the server to start
if curl -s http://localhost:3000 | grep -q "Let's go"; then
echo "Server started successfully and contains 'Let's go'"
else
echo "Server check failed"
exit 1
fi
kill $! # Stop the server
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: deploy to fly 🚀
run: |
cd my-plainweb-project
sed -i 's/app = '"'"'my-app'"'"'/app = '"'"'plainweb-template'"'"'/' fly.toml
sed -i '/\[http_service\]/,/\[/ s/auto_stop_machines = false/auto_stop_machines = true/' fly.toml
sed -i '/\[http_service\]/,/\[/ s/auto_start_machines = false/auto_start_machines = true/' fly.toml
sed -i '/\[http_service\]/,/\[/ s/min_machines_running = 1/min_machines_running = 0/' fly.toml
cat fly.toml
flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_PLAINWEB_TEMPLATE_DEPLOY_TOKEN }}
- name: check fly deployment ⬆️
run: curl -s https://plainweb-template.fly.dev | grep -q "Let's go"