auto-deploy to IPFS
This commit is contained in:
parent
7c39a7f620
commit
a027d922b1
8
.github/github_install_ipfs.sh
vendored
Executable file
8
.github/github_install_ipfs.sh
vendored
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euET -o pipefail
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
wget https://dist.ipfs.tech/kubo/v0.19.1/kubo_v0.19.1_linux-amd64.tar.gz
|
||||||
|
tar -zxf kubo_v0.19.1_linux-amd64.tar.gz
|
||||||
|
PATH="/tmp/kubo:$PATH" ipfs init --profile=lowpower
|
44
.github/github_update_homepage.sh
vendored
Executable file
44
.github/github_update_homepage.sh
vendored
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euET -o pipefail
|
||||||
|
|
||||||
|
echo "Hashing repository contents with IPFS..."
|
||||||
|
|
||||||
|
h="$(ipfs cid base32 "$(ipfs add --recursive --progress --hidden --ignore-rules-path=.ipfsignore --quieter .)")"
|
||||||
|
|
||||||
|
echo "After pinning, the new homepage URL will be: https://$h.ipfs.dweb.link/"
|
||||||
|
|
||||||
|
# Wait for IPFS daemon to be ready
|
||||||
|
echo 'Starting IPFS daemon...'
|
||||||
|
tail -F /tmp/ipfs-daemon.logs -n +1 & pid=$!
|
||||||
|
ipfs daemon >/tmp/ipfs-daemon.logs 2>&1 &
|
||||||
|
while ! grep 'Daemon is ready' /tmp/ipfs-daemon.logs; do sleep 1; date; done
|
||||||
|
echo 'IPFS daemon started, killing log tail...'
|
||||||
|
kill "$pid"
|
||||||
|
echo 'log tail killed'
|
||||||
|
|
||||||
|
# Pin this hash
|
||||||
|
echo "Adding remote pinning service..."
|
||||||
|
(
|
||||||
|
ipfs pin remote service add my-remote-pin "$IPFS_REMOTE_API_ENDPOINT" "$IPFS_REMOTE_TOKEN"
|
||||||
|
) > /dev/null 2>&1
|
||||||
|
|
||||||
|
echo "Connecting to some IPFS node..."
|
||||||
|
(
|
||||||
|
ipfs swarm connect "$IPFS_SWARM_CONNECT_TO"
|
||||||
|
) > /dev/null 2>&1
|
||||||
|
|
||||||
|
echo "Pinning $h on the remote service..."
|
||||||
|
(
|
||||||
|
ipfs pin remote add --service=my-remote-pin --name='site-suzanne.soy-'"$GITHUB_SHA" "$h"
|
||||||
|
) > /dev/null 2>&1
|
||||||
|
echo "Finished pinning $h on the remote service"
|
||||||
|
|
||||||
|
# Update Homepage URL on GitHub
|
||||||
|
curl -L \
|
||||||
|
-X PATCH \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
-H "Authorization: Bearer $API_TOKEN_FOR_UPDATE_HOMEPAGE"\
|
||||||
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
https://api.github.com/repos/SuzanneSoy/SuzanneSoy.github.io \
|
||||||
|
-d '{"name":"SuzanneSoy.github.io", "homepage":"https://dweb.link/ipfs/'"$h"'"}' > /dev/null
|
44
.github/workflows/update-homepage-ipfs.yml
vendored
Normal file
44
.github/workflows/update-homepage-ipfs.yml
vendored
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# Simple workflow for deploying static content to GitHub Pages
|
||||||
|
name: Update repo's Homepage field to the latest IPFS CID
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Runs on pushes targeting the default branch
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
# pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||||
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||||
|
concurrency:
|
||||||
|
group: "pages"
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Single deploy job since we're just deploying
|
||||||
|
deploy:
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
- name: Download IPFS
|
||||||
|
run: ./.github/github_install_ipfs.sh
|
||||||
|
- name: Update homepage URL
|
||||||
|
run: PATH="/tmp/kubo:$PATH" ./.github/github_update_homepage.sh
|
||||||
|
env:
|
||||||
|
API_TOKEN_FOR_UPDATE_HOMEPAGE: ${{ secrets.API_TOKEN_FOR_UPDATE_HOMEPAGE }}
|
||||||
|
IPFS_SWARM_CONNECT_TO: ${{ secrets.IPFS_SWARM_CONNECT_TO }}
|
||||||
|
IPFS_REMOTE_API_ENDPOINT: ${{ secrets.IPFS_REMOTE_API_ENDPOINT }}
|
||||||
|
IPFS_REMOTE_TOKEN: ${{ secrets.IPFS_REMOTE_TOKEN }}
|
Loading…
Reference in New Issue
Block a user