Skip to content

Commit b7a8db5

Browse files
committed
[ci] actions: add swarm upload
1 parent 651245e commit b7a8db5

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

.github/workflows/swarm_upload.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Swarm Upload
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
inputs:
9+
use_latest_tag:
10+
description: 'Deploy latest tag'
11+
required: false
12+
default: true
13+
type: boolean
14+
custom_tag:
15+
description: 'Or specify a custom tag (leave empty to use latest)'
16+
required: false
17+
type: string
18+
jobs:
19+
deploy:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Get latest tag
26+
id: get_tag
27+
run: |
28+
if [ "${{ github.event_name }}" = "push" ]; then
29+
# Tag push trigger
30+
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
31+
echo "trigger=automatic" >> $GITHUB_OUTPUT
32+
else
33+
# Manual trigger
34+
if [ "${{ inputs.custom_tag }}" != "" ]; then
35+
echo "tag=${{ inputs.custom_tag }}" >> $GITHUB_OUTPUT
36+
else
37+
# Get the latest tag
38+
latest_tag=$(git describe --tags --abbrev=0)
39+
echo "tag=$latest_tag" >> $GITHUB_OUTPUT
40+
fi
41+
echo "trigger=manual" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Checkout specific tag
45+
if: github.event_name == 'workflow_dispatch'
46+
run: git checkout ${{ steps.get_tag.outputs.tag }}
47+
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4 # Use the latest major version
50+
with:
51+
node-version: '22'
52+
cache: 'npm'
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Build application
58+
run: npm run build
59+
60+
- name: Upload to Swarm
61+
uses: ethersphere/swarm-actions/upload-dir@latest
62+
id: upload
63+
with:
64+
dir: ./out
65+
index-document: index.html
66+
postage-batch-id: ${{ secrets.PRIVATE_POSTAGE_BATCH_ID }}
67+
bee-url: ${{ secrets.PRIVATE_BEE_URL }}
68+
timeout: 300000
69+
deferred: false
70+
71+
- name: Setup feed
72+
uses: ethersphere/swarm-actions/write-feed@latest
73+
id: feed
74+
with:
75+
reference: ${{ steps.upload.outputs.reference }}
76+
topic: "multichain-ui"
77+
postage-batch-id: ${{ secrets.PRIVATE_POSTAGE_BATCH_ID }}
78+
bee-url: ${{ secrets.PRIVATE_BEE_URL }}
79+
signer: ${{ secrets.MULTICHAIN_PRIVATE_SIGNER }}
80+
81+
- uses: ethersphere/swarm-actions/reference-to-cid@v0
82+
id: cid
83+
with:
84+
reference: ${{ steps.feed.outputs.manifest }}
85+
86+
- run: |
87+
echo 'Chunk Reference: ${{ steps.upload.outputs.reference }}'
88+
echo 'Feed Reference: ${{ steps.feed.outputs.reference }}'
89+
echo 'Feed Manifest: ${{ steps.feed.outputs.manifest }}'
90+
echo 'Feed Bzz.link: https://${{ steps.cid.outputs.cid }}.bzz.link'

0 commit comments

Comments
 (0)