Skip to content

Commit

Permalink
feat(ci): update inbrowser.link on release publish
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Mar 14, 2024
1 parent 8ec199c commit fb0c7d6
Showing 1 changed file with 51 additions and 24 deletions.
75 changes: 51 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
pull_request:
branches:
- '**'
release:
types: [ published ]
workflow_dispatch:

env:
Expand Down Expand Up @@ -167,11 +169,11 @@ jobs:
files: .coverage/*,packages/*/.coverage/*

publish-to-ipfs:
# TODO: make this run also on release
if: github.ref == 'refs/heads/main'
# NOTE: workflow_dispatch here allows maintainer to manually run against any branch, and it will produce a CAR with CID that is pinned
# TODO: if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && github.event.action == 'published')
needs: build
runs-on: ubuntu-latest
environment: Deploy # CF and Clusteer secrets
environment: Deploy # Clusteer secrets
concurrency:
# only one job runs at a time == DNSLinks are updated in-order
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -195,15 +197,14 @@ jobs:
version: "${{ env.CLUSTER_CTL_VER }}"
- name: Init IPFS daemon
run: |
# TODO remove if we no longer need these
# fix resolv - DNS provided by Github is unreliable for DNSLik/dnsaddr
sudo sed -i -e 's/nameserver 127.0.0.*/nameserver 1.1.1.1/g' /etc/resolv.conf
ipfs init --profile flatfs,server,randomports,lowpower
#sudo sed -i -e 's/nameserver 127.0.0.*/nameserver 1.1.1.1/g' /etc/resolv.conf
#ipfs init --profile flatfs,server,randomports,lowpower
# make flatfs async for faster ci
ipfs config --json 'Datastore.Spec.mounts' "$(ipfs config 'Datastore.Spec.mounts' | jq -c '.[0].child.sync=false')"
#ipfs config --json 'Datastore.Spec.mounts' "$(ipfs config 'Datastore.Spec.mounts' | jq -c '.[0].child.sync=false')"
shell: bash
- uses: ipfs/start-ipfs-daemon-action@v1
with:
args: --enable-gc=false
- name: Preconnect to cluster peers
run: |
ipfs-cluster-ctl --enc=json \
Expand Down Expand Up @@ -249,8 +250,8 @@ jobs:
CLUSTER_USER: ${{ secrets.CLUSTER_USER }}
CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }}
timeout-minutes: 60
- name: Update DNSLink at inbrowser.dev (Dev Testing)
if: github.ref == 'refs/heads/main'
- name: Update DNSLink at inbrowser.dev (Staging for Dev Testing) if main branch was updated
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'push') && github.ref == 'refs/heads/main'
run: |
curl --request PUT --header "Authorization: Bearer ${AUTH_TOKEN}" --header 'Content-Type: application/json' \
--url "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
Expand All @@ -261,9 +262,8 @@ jobs:
ZONE_ID: ${{ secrets.CF_INBROWSERDEV_ZONE_ID }}
RECORD_ID: ${{ secrets.CF_INBROWSERDEV_RECORD_ID }}
AUTH_TOKEN: ${{ secrets.CF_INBROWSERDEV_AUTH_TOKEN }}
- name: Update DNSLink at inbrowser.link (Stable Production)
# TODO: make this run only on release
if: github.ref == 'refs/heads/main'
- name: Update DNSLink at inbrowser.link (Stable Production) if new release was published
if: github.event_name == 'release' && github.event.action == 'published'
run: |
curl --request PUT --header "Authorization: Bearer ${AUTH_TOKEN}" --header 'Content-Type: application/json' \
--url "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
Expand All @@ -276,7 +276,7 @@ jobs:
AUTH_TOKEN: ${{ secrets.CF_INBROWSERLINK_AUTH_TOKEN }}

pin-to-w3: # ported from ipfs/ipfs-webui
if: ${{ success() && needs.publish-to-ipfs.outputs.cid }}
if: needs.publish-to-ipfs.outputs.cid
needs: publish-to-ipfs
runs-on: ubuntu-latest
environment: web3.storage
Expand Down Expand Up @@ -313,7 +313,7 @@ jobs:
W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING: ${{ secrets.W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING }}

pin-to-scaleway:
if: ${{ success() && needs.publish-to-ipfs.outputs.cid }}
if: needs.publish-to-ipfs.outputs.cid
needs: publish-to-ipfs
runs-on: ubuntu-latest
environment: Scaleway
Expand Down Expand Up @@ -349,15 +349,42 @@ jobs:
env:
CID: ${{ needs.publish-to-ipfs.outputs.cid }}

smoke-test-http: # basic smoke test that lets us know when eother caching or content routing does not work
if: ${{ success() && needs.publish-to-ipfs.outputs.cid }}
needs: [ publish-to-ipfs, pin-to-scaleway, pin-to-w3 ]
smoke-test-cached-http: # basic smoke test that lets us know when stale-while-revalidate caching does not work on either env
if: needs.publish-to-ipfs.outputs.cid
needs: publish-to-ipfs
runs-on: ubuntu-latest
strategy:
matrix:
dnslink:
- inbrowser.link
- inbrowser.dev
steps:
- name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at inbrowser.link
run: curl --retry 3 --retry-delay 61 --retry-all-errors -v https://inbrowser.link/ipfs-sw-main.js > /dev/null
- name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at inbrowser.dev
run: curl --retry 3 --retry-delay 61 --retry-all-errors -v https://inbrowser.dev/ipfs-sw-main.js > /dev/null
- name: Smoke-test fetching the new CID as CAR from trustless-gateway.link
run: curl --retry 3 --retry-delay 61 --retry-all-errors -v "https://trustless-gateway.link/ipfs/${{ needs.publish-to-ipfs.outputs.cid }}?format=car" > /dev/null
- name: Smoke-test instant (cached, stale-while-revalidate) /ipfs-sw-main.js at ${{ matrix.dnslink }}
run: curl --retry 3 --retry-delay 61 --retry-all-errors -v https://${{ matrix.dnslink }}/ipfs-sw-main.js > /dev/null

smoke-test-fresh-http: # basic smoke test for getting new DAG over HTTP gateways
if: needs.publish-to-ipfs.outputs.cid
needs: publish-to-ipfs
runs-on: ubuntu-latest
strategy:
matrix:
gateway:
- trustless-gateway.link
- cloudflare-ipfs.com
- w3s.link
steps:
- name: Smoke-test fetching the new CID as CAR from ${{ matrix.gateway }}
run: curl --retry 3 --retry-delay 61 --retry-all-errors -v "https://${{ matrix.gateway }}/ipfs/${{ needs.publish-to-ipfs.outputs.cid }}?format=car" > /dev/null

smoke-test-fresh-p2p: # basic smoke test for getting new DAG over P2P with Kubo
if: needs.publish-to-ipfs.outputs.cid
needs: publish-to-ipfs
runs-on: ubuntu-latest
steps:
- uses: ipfs/download-ipfs-distribution-action@v1
with:
name: kubo
version: "${{ env.KUBO_VER }}"
- uses: ipfs/start-ipfs-daemon-action@v1
- name: Smoke-test p2p retrieval with Kubo
run: ipfs dag stat ${{ steps.ipfs-import.outputs.cid }}

0 comments on commit fb0c7d6

Please sign in to comment.