Browse Source

Merge pull request #20 from dskvr/feature/ci

CI/CD
update/libraries
Sandwich 2 years ago
committed by GitHub
parent
commit
6ac8f66e42
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      .github/workflows/deploy.yml
  2. 0
      .github/workflows/publish-events.yml
  3. 21
      .github/workflows/test-relay.yml
  4. 2
      nginx/conf.d/default.conf
  5. 4
      relays.yaml
  6. 7
      src/App.vue
  7. 1
      src/components/NavComponent.vue
  8. 28
      src/components/RefreshComponent.vue

40
.github/workflows/deploy.yml

@ -0,0 +1,40 @@
name: Build & Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Yarn Install
run: yarn install
- name: Docker Build & tag
run: |
yarn docker:build
yarn docker:tag
- name: Configure doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Login to doctl registry
run: doctl registry login -t ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Docker Deploy
run: |
yarn docker:deploy
- name: Pull new image and restart
uses: appleboy/ssh-action@v0.1.2
with:
host: ${{secrets.SSH_DEPLOY_HOST}}
key: ${{secrets.SSH_DEPLOY_KEY}}
username: ${{ secrets.SSH_DEPLOY_USERNAME }}
script: docker pull registry.digitalocean.com/sandwich-farm/nostr-relay-status:latest && docker-compose stop && docker-compose up -d

0
.github/workflows/publish-events.yml

21
.github/workflows/test-relay.yml

@ -0,0 +1,21 @@
name: Test Relay
on:
pull_request:
paths:
- 'relays.yaml'
jobs:
check_relay:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
+(src|__tests__)/**/*.ts
!src/exclude.ts
FILES: |
relays.yml
- name: Check differences
run: echo ${{ env.GIT_DIFF }}

2
nginx/conf.d/default.conf

@ -1,6 +1,7 @@
server { server {
listen 80; listen 80;
root /app; root /app;
error_page 404 =200 /index.html;
location / { location / {
index index.html; index index.html;
@ -8,6 +9,7 @@ server {
} }
location ~ /?(.*)$ { location ~ /?(.*)$ {
index index.html; index index.html;
} }
} }

4
relays.yaml

@ -1,5 +1,6 @@
relays: relays:
# - 'wss://rsslay.fiatjaf.com' - 'wss://rsslay.fiatjaf.com'
- 'wss://relayer.fiatjaf.com'
- 'wss://freedom-relay.herokuapp.com/ws' - 'wss://freedom-relay.herokuapp.com/ws'
- 'wss://nostr-relay.freeberty.net' - 'wss://nostr-relay.freeberty.net'
- 'wss://nostr-relay.wlvs.space' - 'wss://nostr-relay.wlvs.space'
@ -26,7 +27,6 @@ relays:
- 'wss://relay.grunch.dev' - 'wss://relay.grunch.dev'
- 'wss://relay.cynsar.foundation' - 'wss://relay.cynsar.foundation'
- 'wss://nostr-pub.wellorder.net' - 'wss://nostr-pub.wellorder.net'
# - 'wss://relayer.fiatjaf.com'
- 'wss://relay.oldcity-bitcoiners.info' - 'wss://relay.oldcity-bitcoiners.info'
- 'wss://relay.bitid.nz' - 'wss://relay.bitid.nz'
- 'wss://relay.nostr.xyz' - 'wss://relay.nostr.xyz'

7
src/App.vue

@ -1,5 +1,6 @@
<template> <template>
<router-view></router-view> <router-view></router-view>
<a id="fork-me" href="https://github.com/dskvr/nostr-watch"><img decoding="async" loading="lazy" width="149" height="149" src="https://github.blog/wp-content/uploads/2008/12/forkme_right_darkblue_121621.png?resize=149%2C149" class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a>
</template> </template>
<script> <script>
@ -18,4 +19,10 @@ export default {
text-align: center; text-align: center;
color: #2c3e50; color: #2c3e50;
} }
#fork-me {
position:absolute;
top: 0px;
right:0px;
z-index: 9999;
}
</style> </style>

1
src/components/NavComponent.vue

@ -7,6 +7,7 @@
<span> <span>
<PreferencesComponent /> <PreferencesComponent />
</span> </span>
</ul> </ul>
</nav> </nav>
</template> </template>

28
src/components/RefreshComponent.vue

@ -25,6 +25,19 @@ const localMethods = {
nextRefresh: function(){ nextRefresh: function(){
return this.timeSince(Date.now()-(this.lastUpdate+this.preferences.cacheExpiration-Date.now())) return this.timeSince(Date.now()-(this.lastUpdate+this.preferences.cacheExpiration-Date.now()))
}, },
setRefreshInterval: function(){
this.interval = setInterval(() => {
if(!this.preferences.refresh) return false
this.preferences = this.getState('preferences') || this.preferences
this.refreshData.untilNext = this.timeUntilRefresh()
this.refreshData.sinceLast = this.timeSinceRefresh()
if(this.isExpired())
this.invalidate()
}, 1000)
}
} }
export default defineComponent({ export default defineComponent({
@ -40,16 +53,8 @@ export default defineComponent({
sinceLast: this.timeSinceRefresh() sinceLast: this.timeSinceRefresh()
}) })
setInterval(() => { if(this.preferences.refresh)
this.preferences = this.getState('preferences') || this.preferences this.setRefreshInterval()
this.refreshData.untilNext = this.timeUntilRefresh()
this.refreshData.sinceLast = this.timeSinceRefresh()
if(this.isExpired())
this.invalidate()
}, 1000)
}, },
updated(){ updated(){
this.saveState('preferences') this.saveState('preferences')
@ -61,6 +66,9 @@ export default defineComponent({
this.refreshData.untilNext = this.timeUntilRefresh() this.refreshData.untilNext = this.timeUntilRefresh()
this.refreshData.sinceLast = this.timeSinceRefresh() this.refreshData.sinceLast = this.timeSinceRefresh()
if(this.preferences.refresh)
this.setRefreshInterval()
}, },
computed: {}, computed: {},
methods: Object.assign(localMethods, sharedMethods), methods: Object.assign(localMethods, sharedMethods),

Loading…
Cancel
Save