Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anotherjesse/hello-hyper-github-publish
https://github.com/anotherjesse/hello-hyper-github-publish
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/anotherjesse/hello-hyper-github-publish
- Owner: anotherjesse
- Created: 2020-12-06T18:22:45.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-06T23:26:06.000Z (about 4 years ago)
- Last Synced: 2024-06-22T13:45:25.380Z (6 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Svelte: Github commit -> published to hyperdrive
This is a simple proof of concept of publishing a compiled svelte app to a hyperdrive upon commit.
The contained github action will build and then publish to hyper://e89224ea508fedaa196396a4b8f326da5e0e9e4cc34ddb5e382872fbb020aaee
We will use:
- svelte repl / https://svelte.dev/repl - to bootstrap our app
- hyperdrive-publisher - https://github.com/RangerMauve/hyperdrive-publisher - to create / update our hyperdrive
- dat-store - https://github.com/datproject/dat-store - to peer/pin our hyperdrive
- beakerbrowser - https://beakerbrowser.com - to view our hyperdrive & app## Step 0: Setting up dat-store
`hyperdrive-publisher` creates and updates hyperdrives, but you will need to persist the drive in at least one peer.
I recommend using [dat-store](https://github.com/datproject/dat-store) on a server (raspberry pi or tiny cloud vm).
The hole punching p2p functionality of hyper doesn't work well for me, so I find exposing `dat-store` peering ports directly on the web helps a lot.
I'm running my instance of `dat-store` on a google cloud vm:
Firewall Rules:
Source filters
IP ranges 0.0.0.0/0
Protocols and ports
tcp:3282
udp:3282## Step 1: Create a new hyperdrive
To create a hyperdrive that you will publish to using github actions, you will run the command `hyperdrive-publisher create` (either on your local system or a remote server).
$ hyperdrive-publisher create
Seed:
c343220bd25b2c88cf313f349761b8347bd31c3002ba123d29b88d4ea755eff5
URL:
hyper://792f244134c0956c6ff26d1de88cff0a793cf52561ec0e2fd526e1e48d23bc76
Initializing Hyperdrive
Please add this URL to a pinning service like dat-store to continue
I then go to my cloud instance and add that hyper url to `dat-store` peering list:node bin.js add hyper://792f244134c0956c6ff26d1de88cff0a793cf52561ec0e2fd526e1e48d23bc76
Back on my local system, I see that my new hyperdrive has been peered!
Connected {
remoteAddress: '::ffff:10.128.0.3',
remoteType: 'tcp',
remotePublicKey:
}
Waiting to sync metadata
Synced
You can sync a folder with:
hyperdrive-publisher sync c343220bd25b2c88cf313f349761b8347bd31c3002ba123d29b88d4ea755eff5At this point the hyperdrive should be accessible (from Beaker or other hyper clients) but will be empty except for an `index.json` file.
NOTE: you need to save the `seed` and keep it private. Anyone with the seed can publish to the hyperdrive!
## Step 2: publishing to hyperdrive via github actions
We can create a new github repository and add an action by copying [publish.yml from RangerMauve's example](https://github.com/RangerMauve/hyperdrive-publisher-example/blob/default/.github/workflows/publish.yml)
By default the sample publishes all the files from a checkout of the git repository. To publish only the generated archive, make a small change to the action by adding `public/`" to end of the line:
- name: Run Publisher
run: npx hyperdrive-publisher sync ${{ secrets.PUBLISHER_KEY }} public/Additionally on github you will need to go to the repository settings and create a secret called `PUBLISHER_KEY` and paste in the `seed` that was provided in Step 1.
## Step 3: Svelte App
This is the simplest svelte app, which was created by going to https://svelte.dev/repl and changing name to `svelte` then clicking download.
Place the downloaded files in the root of the git repository, then we must add a step to install the dependencies and compile the svelte app.
Adding the following steps to the action before the hyperdrive-publisher step:
- name: install app deps
run: npm i
- name: compile app
run: npm run buildAt this point pushing to github should trigger the action. Seconds later you should see the completed application in your hyper url in Beaker!