44 release :
55 types : [published]
66
7- env :
8- REGISTRY : ghcr.io
9- IMAGE_NAME : ${{ github.repository }}
10-
117jobs :
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"
0 commit comments