Deploying with Github Actions
If you are used to deploying to GitHub pages or any other hosting provider
that uses GitHub actions, actions-distributed-press
allows you to
just add a single step to your actions workflow to also deploy a bundle
of static files to Distributed Press.
Distributed Press only supports deploying a folder of static files. Most frameworks like Next.js, React, and Hugo, allow you to 'export' or 'build' your site as bunch of static files.
Read the source here (opens in a new tab)
To your existing action workflow, add a step to publish to Distributed Press. Additionally, add an encrypted secret in your repository (opens in a new tab) containing a valid refresh token issued your specified Distributed Press API instance.
The name of the secret should be REFRESH_TOKEN
and the value should be the JWT itself.
If you are unsure where to get a JWT token, see the reference on authorization.
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
... steps to build your site go here
- name: Publish to Distributed Press
uses: hyphacoop/actions-distributed-press@v1.1
with:
publish_dir: public # (optional) defaults to /public
dp_url: https://your-hosted.dp.instance # URL of Distributed Press API Instance (include http/https)
refresh_token: ${{ secrets.REFRESH_TOKEN }} # Refresh token
site_url: docs.distributed.press # Site domain (as created through the API)
deploy_http: false
deploy_hyper: true
deploy_ipfs: true
Example Next.js Deployment
In your repository, create a new file github/workflows/deploy-distributed-press.yaml
name: "Publish GitHub Action"
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm run build
- name: Publish to Distributed Press
uses: hyphacoop/actions-distributed-press@v1.1
with:
publish_dir: public
dp_url: https://your-hosted.dp.instance
refresh_token: ${{ secrets.REFRESH_TOKEN }}
site_url: docs.distributed.press
This will build and publish your site to the Distributed Press
instance hosted at https://your-hosted.dp.instance