Skip to content

Commit 25063cd

Browse files
committed
ci: auto-deploy to Appwrite Sites on every push to main
Packages the static site and creates an activated deployment on the 'portfolio' site (tapiwa.me) via the Appwrite API, then waits for it to go live. Uses the sites-scoped APPWRITE_API_KEY repo secret.
1 parent 825e47d commit 25063cd

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy to Appwrite Sites
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: appwrite-deploy
10+
cancel-in-progress: true
11+
12+
jobs:
13+
deploy:
14+
name: Deploy tapiwa.me
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
# Static site: ship the repo as-is (minus git/CI internals).
20+
- name: Package site
21+
run: |
22+
tar --exclude='.git' --exclude='.github' -czf /tmp/code.tar.gz .
23+
ls -la /tmp/code.tar.gz
24+
25+
- name: Create + activate deployment
26+
env:
27+
APPWRITE_API_KEY: ${{ secrets.APPWRITE_API_KEY }}
28+
run: |
29+
set -euo pipefail
30+
resp=$(curl -sS -X POST \
31+
"https://fra.cloud.appwrite.io/v1/sites/portfolio/deployments" \
32+
-H "X-Appwrite-Project: 69e62515000e9e781653" \
33+
-H "X-Appwrite-Key: $APPWRITE_API_KEY" \
34+
-F "code=@/tmp/code.tar.gz" \
35+
-F "activate=true")
36+
echo "$resp"
37+
dep_id=$(echo "$resp" | python3 -c "import json,sys; print(json.load(sys.stdin)['\$id'])")
38+
echo "deployment: $dep_id"
39+
40+
# Wait until the deployment goes live (static adapter builds fast).
41+
for i in $(seq 1 30); do
42+
sleep 10
43+
status=$(curl -sS \
44+
"https://fra.cloud.appwrite.io/v1/sites/portfolio/deployments/$dep_id" \
45+
-H "X-Appwrite-Project: 69e62515000e9e781653" \
46+
-H "X-Appwrite-Key: $APPWRITE_API_KEY" \
47+
| python3 -c "import json,sys; print(json.load(sys.stdin)['status'])")
48+
echo "status: $status"
49+
case "$status" in
50+
ready) echo "deployed ✔"; exit 0 ;;
51+
failed|canceled) echo "deployment $status" >&2; exit 1 ;;
52+
esac
53+
done
54+
echo "timed out waiting for deployment" >&2
55+
exit 1

0 commit comments

Comments
 (0)