Skip to content

Commit 6ada4bc

Browse files
committed
feat: automated deployment via GitHub Actions + ghcr.io + Render deploy hooks
- .github/workflows/deploy.yml: on push to main or manual trigger Builds linux/amd64 images, pushes to ghcr.io, triggers Render deploy hooks Uses GHA cache for fast rebuilds - render.yaml: docker.io/muness/* -> ghcr.io/open-horizon-labs/northwoods-* No public Docker Hub images - RENDER_API_KEY set as GitHub secret Flow: push to main -> GH Action builds 3 images (matrix) -> pushes to ghcr.io -> triggers Render API deploys -> waits for all services live
1 parent 2772705 commit 6ada4bc

2 files changed

Lines changed: 100 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Deploy to Render
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: deploy
10+
cancel-in-progress: true
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}/northwoods
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
strategy:
23+
matrix:
24+
include:
25+
- name: api
26+
dockerfile: src/Services/Northwoods.Api/Dockerfile
27+
context: src/
28+
- name: worker
29+
dockerfile: src/Workers/Extraction.Worker/Dockerfile
30+
context: src/
31+
- name: web
32+
dockerfile: apps/web/Dockerfile
33+
context: .
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: docker/setup-buildx-action@v3
38+
39+
- uses: docker/login-action@v3
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- uses: docker/build-push-action@v5
46+
with:
47+
context: ${{ matrix.context }}
48+
file: ${{ matrix.dockerfile }}
49+
platforms: linux/amd64
50+
push: true
51+
tags: ${{ env.IMAGE_PREFIX }}-${{ matrix.name }}:latest,${{ env.IMAGE_PREFIX }}-${{ matrix.name }}:${{ github.sha }}
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max
54+
55+
deploy:
56+
needs: build-and-push
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Trigger Render deploys
60+
env:
61+
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }}
62+
run: |
63+
for SVC in srv-d73ber19fqoc73ci2l60 srv-d73bervkijhs73dee48g srv-d73bhic2kvos738c3t6g; do
64+
echo "Deploying $SVC..."
65+
curl -sf -X POST "https://api.render.com/v1/services/$SVC/deploys" \
66+
-H "Authorization: Bearer $RENDER_API_KEY" \
67+
-H "Content-Type: application/json" \
68+
-d '{"clearCache":"do_not_clear"}' \
69+
| jq -r '.id // "triggered"'
70+
done
71+
72+
- name: Wait for deploys
73+
env:
74+
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }}
75+
run: |
76+
echo "Waiting for services to go live..."
77+
for attempt in $(seq 1 30); do
78+
sleep 15
79+
ALL_LIVE=true
80+
for SVC in srv-d73ber19fqoc73ci2l60 srv-d73bervkijhs73dee48g srv-d73bhic2kvos738c3t6g; do
81+
STATUS=$(curl -sf -H "Authorization: Bearer $RENDER_API_KEY" \
82+
"https://api.render.com/v1/services/$SVC/deploys?limit=1" \
83+
| jq -r '.[0].deploy.status')
84+
if [ "$STATUS" != "live" ]; then
85+
ALL_LIVE=false
86+
fi
87+
done
88+
if [ "$ALL_LIVE" = "true" ]; then
89+
echo "All services live!"
90+
exit 0
91+
fi
92+
echo "Attempt $attempt: not all live yet..."
93+
done
94+
echo "Timeout waiting for deploys" && exit 1

render.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Render Blueprint for Northwoods deployment
22
# See: https://render.com/docs/blueprint-spec
33
#
4-
# Note: This blueprint documents the service topology. Services were created
5-
# via the Render API and deploy from Docker Hub images (muness/northwoods-*).
6-
# To use this blueprint directly, connect the GitHub repo to Render first.
4+
# Images built by GitHub Actions (.github/workflows/deploy.yml) and pushed
5+
# to GitHub Container Registry (ghcr.io). Render pulls on deploy hook trigger.
6+
# No public Docker Hub images.
77

88
databases:
99
- name: northwoods-db
@@ -20,7 +20,7 @@ services:
2020
region: oregon
2121
runtime: image
2222
image:
23-
url: docker.io/muness/northwoods-api:latest
23+
url: ghcr.io/open-horizon-labs/northwoods-api:latest
2424
healthCheckPath: /healthz
2525
envVars:
2626
- key: ASPNETCORE_URLS
@@ -67,7 +67,7 @@ services:
6767
region: oregon
6868
runtime: image
6969
image:
70-
url: docker.io/muness/northwoods-worker:latest
70+
url: ghcr.io/open-horizon-labs/northwoods-worker:latest
7171
envVars:
7272
- key: ConnectionStrings__Default
7373
fromDatabase:
@@ -113,5 +113,5 @@ services:
113113
region: oregon
114114
runtime: image
115115
image:
116-
url: docker.io/muness/northwoods-web:latest
116+
url: ghcr.io/open-horizon-labs/northwoods-web:latest
117117
# Custom domain: northwoods.muness.com (CNAME via Cloudflare)

0 commit comments

Comments
 (0)