-
Notifications
You must be signed in to change notification settings - Fork 2
91 lines (85 loc) · 2.74 KB
/
swarm.yml
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
81
82
83
84
85
86
87
88
89
90
91
name: push to swarm
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
defaults:
run:
working-directory: .
strategy:
matrix:
node-version: [18.x]
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set environment specific variables
uses: jnus/[email protected]
with:
scope: ${{ github.ref_name }}
configFile: ".github/workflows/variables.json"
secrets: "${{ toJson(secrets.github_token) }}"
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: install
run: npm ci
- name: copy NEXT vars to .env
run: |
env |grep 'REACT_' > .env
- name: build
run: npm run build
env:
CI: false
- name: Upload
id: swarm-upload
uses: ethersphere/swarm-actions/upload-dir@latest
with:
bee-url: ${{ env.SWARM_URL }}
dir: ./build
index-document: index.html
pin: true
timeout: 20000
- name: update feed
id: swarm-feed
uses: ethersphere/swarm-actions/write-feed@latest
env:
SIGNER: SIGNER_${{ github.ref_name}}
with:
bee-url: ${{ env.SWARM_URL }}
reference: ${{ steps.swarm-upload.outputs.reference }}
topic: create
signer: ${{ secrets[env.SIGNER] }}
- name: get CID
id: swarm-cid
uses: ethersphere/swarm-actions/reference-to-cid@latest
with:
reference: ${{ steps.swarm-feed.outputs.reference }}
- name: print
run: |
echo "upload ref: " ${{ steps.swarm-upload.outputs.reference }}
echo "feed ref: " ${{ steps.swarm-feed.outputs.reference }}
echo "CID: " ${{ steps.swarm-cid.outputs.cid }}
echo 'Feed Manifest: ${{ steps.swarm-feed.outputs.manifest }}'
- name: purge cache
env:
TOKEN: "${{ secrets.purge_token }}"
run: |
curl -s ${{ env.PURGE_URL }}/deploy/purge?token=${{ secrets.purge_token }} -H "site: create${{ env.DEPLOYMENT }}fairdrive.io" -H "uri: *"