Skip to content

Commit 46f7fa7

Browse files
authored
chore(ci): deploy after release (#55)
1 parent 0c5c9a1 commit 46f7fa7

File tree

3 files changed

+30
-73
lines changed

3 files changed

+30
-73
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: CI Checks
33
on:
44
pull_request:
55
push:
6-
branches: [main]
6+
branches:
7+
- main
78

89
concurrency:
910
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'

.github/workflows/release.yml

Lines changed: 26 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,13 @@ on:
44
release:
55
types: [published]
66

7-
env:
8-
REGISTRY: ghcr.io
9-
IMAGE_NAME: ${{ github.repository }}
10-
117
jobs:
12-
lint:
13-
name: Lint
14-
runs-on: ubuntu-latest
15-
container:
16-
image: node:18-alpine3.16
17-
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-node@v3
20-
with:
21-
node-version-file: .nvmrc
22-
cache: npm
23-
- name: Install package dependencies
24-
run: npm ci
25-
- name: Run ESLint
26-
run: npm run lint
27-
build:
28-
name: Build
29-
runs-on: ubuntu-latest
30-
container:
31-
image: node:18-alpine3.16
32-
needs: [lint]
33-
steps:
34-
- uses: actions/checkout@v3
35-
- uses: actions/setup-node@v3
36-
with:
37-
node-version-file: .nvmrc
38-
cache: npm
39-
- name: Install package dependencies
40-
run: npm ci
41-
- name: Run ESLint
42-
run: npm run build
43-
test:
44-
name: Tests
45-
runs-on: ubuntu-latest
46-
container:
47-
image: node:18-alpine3.16
48-
needs: [build]
49-
steps:
50-
- uses: actions/checkout@v3
51-
- uses: actions/setup-node@v3
52-
with:
53-
node-version-file: .nvmrc
54-
cache: npm
55-
- name: Install package dependencies
56-
run: npm ci
57-
- name: Run tests
58-
run: npm run test:unit
59-
coverage:
60-
name: Coverage
61-
runs-on: ubuntu-latest
62-
container:
63-
image: node:18-alpine3.16
64-
needs: [build]
65-
environment: development
66-
steps:
67-
- uses: actions/checkout@v3
68-
- uses: actions/setup-node@v3
69-
with:
70-
node-version-file: .nvmrc
71-
cache: npm
72-
- name: Install package dependencies
73-
run: npm ci
74-
- name: Run coverage
75-
run: npm run cover
768
build-and-push-image:
779
name: Build and push container image
7810
runs-on: ubuntu-latest
79-
needs: [coverage, test]
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
8014
permissions:
8115
contents: read
8216
packages: write
@@ -101,3 +35,26 @@ jobs:
10135
push: true
10236
tags: ${{ steps.meta.outputs.tags }}
10337
labels: ${{ steps.meta.outputs.labels }}
38+
deploy:
39+
name: Deploy
40+
runs-on: ubuntu-latest
41+
environment: deployment
42+
env:
43+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v3
47+
- name: Setup SSH key
48+
run: |
49+
ssh-agent -t 60 -a $SSH_AUTH_SOCK > /dev/null
50+
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
51+
- name: Setup known hosts
52+
run: mkdir -p ~/.ssh && chmod 700 ~/.ssh && ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
53+
- name: Setup SSH config
54+
run: |
55+
mkdir -p ~/.ssh/sockets && chmod 700 ~/.ssh/sockets
56+
echo "Host *\n User ${{ secrets.SSH_USER }}\n ForwardAgent yes\n ControlMaster auto\n ControlPath ~/.ssh/sockets/%r@%h-%p\n ControlPersist 600" >> ~/.ssh/config
57+
chmod 600 ~/.ssh/config
58+
- name: Deploy
59+
run: |
60+
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -o SendEnv=GITHUB_REF_NAME "cd /srv/nostr-ts-relay && git fetch -va origin && git checkout --progress --force -B $GITHUB_REF_NAME refs/remotes/origin/$GITHUB_REF_NAME && source ~/.nvm/nvm.sh && nvm use && npm run tor:docker:compose:start -- --detach"

docker-compose.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ services:
88
DB_USER: nostr_ts_relay
99
DB_PASSWORD: nostr_ts_relay
1010
DB_NAME: nostr_ts_relay
11-
DB_MIN_POOL_SIZE: 1
12-
DB_MAX_POOL_SIZE: 2
11+
DB_MIN_POOL_SIZE: 2
12+
DB_MAX_POOL_SIZE: 10
1313
NOSTR_CONFIG_DIR: /home/node/
1414
PORT: 8008
15-
DEBUG: worker:event-message-handler,worker:web-socket-server-adapter
1615
user: node:node
1716
volumes:
1817
- $HOME/.nostr:/home/node/

0 commit comments

Comments
 (0)