push to swarm #293
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: push to swarm | |
### run this action when something is pushed to master branch | |
on: | |
push: | |
branches: [ master ] | |
schedule: | |
- cron: '9 9 1,15 * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true # Fetch Hugo themes (true OR recursive) | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.0' # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
cache-version: 1 # Increment this number if you need to re-download cached gems | |
- run: bundle exec jekyll build --baseurl "" --destination ./dist # defaults output to '/_site' | |
### upload the content of public folder to swarm | |
- name: Upload | |
id: swarm-upload | |
uses: ethersphere/swarm-actions/upload-dir@latest | |
with: | |
# Fairdatasociety provides a free endpoint for uploading content to swarm | |
# use .dev. for testnet uploads | |
# or remove .dev. for mainnet uploads | |
# or use your own private endpoint | |
bee-url: https://gateway.fairdatasociety.org/proxy/ | |
dir: ./dist | |
index-document: index.html | |
timeout: 120000 | |
pin: true | |
- name: update feed | |
id: swarm-feed | |
uses: ethersphere/swarm-actions/write-feed@latest | |
with: | |
# Same as above regarding bee-url | |
bee-url: https://gateway.fairdatasociety.org/proxy/ | |
# takes the reference from the uploaded dir | |
reference: ${{ steps.swarm-upload.outputs.reference }} | |
# make up some topic name | |
# for example: # openssl rand -hex 16 | |
topic: a022076ed9689fb041476a4f60ab7153 | |
# signer you will want to put into your projects secrets | |
# again use some random hex 32 length generation | |
# for example: openssl rand -hex 32 and put the output into gihub secrets named "SIGNER" | |
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository | |
signer: ${{ secrets.SIGNER }} | |
# print some references of what we just uploaded to swarm | |
- name: print references | |
run: | | |
echo "upload ref: " ${{ steps.swarm-upload.outputs.reference }} # you can use this to access the content directly https://gateway.dev.fairdatasociety.org/bzz/<refrence> | |
echo "CID: " ${{ steps.swarm-cid.outputs.cid }} # same but in cid format | |
echo "Feed Manifest: " ${{ steps.swarm-feed.outputs.manifest }} # note this reference, you will need this in next step to create a persistant reference to it using ENS | |
- name: purge cache | |
env: | |
TOKEN: '${{ secrets.purge_token }}' | |
DEPLOYMENT: . | |
PURGE_URL: 'https://fairos.staging.fairdatasociety.org' | |
run: | | |
curl -s ${{ env.PURGE_URL }}/deploy/purge?token=${{ secrets.purge_token }} -H "site: fairdataprotocol.link{{ env.DEPLOYMENT }}fairdatasociety.org" -H "uri: " |