Repository navigation
80 lines (62 loc) · 2.37 KB
/
Copy pathhash-deploy-build.yml
File metadata and controls
80 lines (62 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Hash and Deploy to IPFS
on:
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: write
jobs:
build-hash-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build Production
run: ./scripts/build-production.sh
- name: Install Kubo (IPFS CLI)
run: |
wget -q https://dist.ipfs.tech/kubo/v0.34.1/kubo_v0.34.1_linux-amd64.tar.gz
tar -xzf kubo_v0.34.1_linux-amd64.tar.gz
sudo cp kubo/ipfs /usr/local/bin/
ipfs init --profile=badgerds
ipfs version
- name: Generate IPFS Hash
id: ipfs
run: |
HASH=$(ipfs add -r -Q --chunker=size-262144 --raw-leaves=false ./dist)
HASH_V1=$(ipfs cid format -v 1 -b base32 $HASH)
echo "hash_v0=$HASH" >> $GITHUB_OUTPUT
echo "hash_v1=$HASH_V1" >> $GITHUB_OUTPUT
echo "IPFS Hash (v0): $HASH"
echo "IPFS Hash (v1): $HASH_V1"
- name: Update IPFS Hash in Repo
run: |
HASH="${{ steps.ipfs.outputs.hash_v0 }}"
# Create shields.io endpoint format JSON
mkdir -p /tmp/ipfs-meta
echo "{\"schemaVersion\": 1, \"label\": \"IPFS\", \"message\": \"$HASH\", \"color\": \"blue\", \"namedLogo\": \"ipfs\"}" > /tmp/ipfs-meta/ipfs-hash.json
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Fetch or create the meta branch
git fetch origin meta:meta 2>/dev/null || git checkout --orphan meta
git checkout meta || git checkout --orphan meta
# Clean and add only the hash file
git rm -rf . 2>/dev/null || true
cp /tmp/ipfs-meta/ipfs-hash.json .
git add ipfs-hash.json
if git diff --staged --quiet; then
echo "No changes to IPFS hash"
else
git commit -m "chore: update IPFS hash to $HASH"
git push origin meta
fi
# Switch back to main
git checkout main
echo "Updated meta branch with IPFS hash: $HASH"