Skip to content

Commit 579fa59

Browse files
Remove CI and change docs (#1)
1 parent a88504d commit 579fa59

File tree

5 files changed

+91
-181
lines changed

5 files changed

+91
-181
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

.github/workflows/full-deploy.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Thanks for your interest in contributing. This document covers the branch model,
1313

1414
**Release flow:**
1515
1. As PRs merge to `develop`, the changeset bot opens and maintains a **"chore: release vX.Y.Z"** PR targeting `main`
16-
2. Merging that PR to `main` triggers a deploy and creates a GitHub release automatically
16+
2. Merging that PR to `main` creates a GitHub release automatically
1717
3. A **"chore: sync main → develop"** PR is then opened automatically — merge it to keep `develop` up to date
1818

1919
---

README.md

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,101 @@ Open a pull request on one of the repos where Layne is installed. Within a few s
230230

231231
### Automated Deployment
232232

233-
Layne ships with a GitHub Actions workflow (`.github/workflows/deploy.yml`) that runs tests and then deploys to your EC2 instance on every push to `main`. It can also be triggered manually from the Actions tab via `workflow_dispatch`.
233+
Here is the GitHub Actions workflow we use internally to deploy Layne to an EC2 instance on every push to `main`. Copy it into your own repository's `.github/workflows/deploy.yml` and configure the secrets below.
234234

235-
**What the workflow does:**
235+
The workflow:
236236

237237
1. Runs the full test suite — the deploy step is skipped if tests fail
238238
2. Rsyncs the repository to `/home/ubuntu/layne/layne/` on the server, preserving `data/` (certbot certificates) and never touching `.env`
239239
3. Writes a fresh `.env` file from GitHub secrets
240240
4. Runs `docker compose up --build --no-deps -d server worker` — rebuilds and restarts only the server and worker, leaving Redis (and the BullMQ queue) untouched
241241

242+
```yaml
243+
name: Deploy
244+
245+
on:
246+
push:
247+
branches: [main]
248+
workflow_dispatch:
249+
250+
jobs:
251+
test:
252+
runs-on: ubuntu-latest
253+
steps:
254+
- uses: actions/checkout@v4
255+
- uses: actions/setup-node@v4
256+
with:
257+
node-version: '22'
258+
cache: 'npm'
259+
- run: npm ci
260+
- run: npm run lint
261+
- run: npm run validate-config
262+
- run: npm test
263+
264+
deploy:
265+
needs: test
266+
runs-on: ubuntu-latest
267+
environment: production
268+
269+
steps:
270+
- uses: actions/checkout@v4
271+
272+
- name: Set up SSH
273+
run: |
274+
mkdir -p ~/.ssh
275+
echo "${{ secrets.EC2_SSH_KEY }}" | tr -d '\r' > ~/.ssh/deploy_key
276+
chmod 600 ~/.ssh/deploy_key
277+
echo "Host deploy-target" >> ~/.ssh/config
278+
echo " HostName ${{ secrets.EC2_HOST }}" >> ~/.ssh/config
279+
echo " User ubuntu" >> ~/.ssh/config
280+
echo " IdentityFile ~/.ssh/deploy_key" >> ~/.ssh/config
281+
echo " StrictHostKeyChecking no" >> ~/.ssh/config
282+
echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config
283+
284+
- name: Sync code to server
285+
run: |
286+
rsync -az --delete \
287+
--exclude='.git' \
288+
--exclude='node_modules' \
289+
--exclude='.env' \
290+
--exclude='data' \
291+
--exclude='coverage' \
292+
-e "ssh -F $HOME/.ssh/config" \
293+
./ deploy-target:/home/ubuntu/layne/layne/
294+
295+
- name: Write .env from secrets
296+
env:
297+
GH_APP_ID: ${{ secrets.GH_APP_ID }}
298+
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
299+
GH_WEBHOOK_SECRET: ${{ secrets.GH_WEBHOOK_SECRET }}
300+
DOMAIN: ${{ secrets.DOMAIN }}
301+
LETSENCRYPT_EMAIL: ${{ secrets.LETSENCRYPT_EMAIL }}
302+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
303+
ROCKETCHAT_WEBHOOK_URL: ${{ secrets.ROCKETCHAT_WEBHOOK_URL }}
304+
METRICS_ENABLED: ${{ vars.METRICS_ENABLED }}
305+
METRICS_PORT: ${{ vars.METRICS_PORT }}
306+
run: |
307+
{
308+
printf 'GITHUB_APP_ID=%s\n' "$GH_APP_ID"
309+
printf 'GITHUB_APP_PRIVATE_KEY=%s\n' "$GH_APP_PRIVATE_KEY"
310+
printf 'GITHUB_WEBHOOK_SECRET=%s\n' "$GH_WEBHOOK_SECRET"
311+
printf 'DOMAIN=%s\n' "$DOMAIN"
312+
printf 'LETSENCRYPT_EMAIL=%s\n' "$LETSENCRYPT_EMAIL"
313+
printf 'ANTHROPIC_API_KEY=%s\n' "$ANTHROPIC_API_KEY"
314+
printf 'ROCKETCHAT_WEBHOOK_URL=%s\n' "$ROCKETCHAT_WEBHOOK_URL"
315+
printf 'METRICS_ENABLED=%s\n' "${METRICS_ENABLED:-false}"
316+
printf 'METRICS_PORT=%s\n' "${METRICS_PORT:-9091}"
317+
} | ssh -F "$HOME/.ssh/config" deploy-target \
318+
'cat > /home/ubuntu/layne/layne/.env'
319+
320+
- name: Rebuild and restart server and worker
321+
run: |
322+
ssh -F "$HOME/.ssh/config" deploy-target \
323+
'cd /home/ubuntu/layne/layne &&
324+
docker compose up --build --no-deps -d server worker &&
325+
docker compose exec nginx nginx -s reload'
326+
```
327+
242328
**Required GitHub secrets:**
243329
244330
Go to your repository → **Settings → Secrets and variables → Actions** and add:
@@ -264,7 +350,7 @@ Go to your repository → **Settings → Secrets and variables → Actions** and
264350

265351
> **Note:** GitHub reserves the `GITHUB_` prefix for its own built-in variables, so the three app secrets use a `GH_` prefix here. The workflow maps them to the correct `GITHUB_`-prefixed names when writing `.env`.
266352

267-
The workflow uses a GitHub [**environment**](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment) named `production`. You can configure deployment protection rules on that environment (e.g. require a manual approval before deploying to production).
353+
The workflow uses a GitHub [**environment**](https://docs.github.com/en/actions/deployment/targeting-different-deployment-environments) named `production`. You can configure deployment protection rules on that environment (e.g. require a manual approval before deploying to production).
268354

269355
---
270356

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration
22

3-
Scanner behaviour, labels, and notifications are all configured in `config/repos.json`. Layne reads this file once at worker startup — **restart the worker to pick up changes** (the automated deploy pipeline does this automatically).
3+
Scanner behaviour, labels, and notifications are all configured in `config/repos.json`. Layne reads this file once at worker startup — **restart the worker to pick up changes**.
44

55
---
66

0 commit comments

Comments
 (0)