File tree 3 files changed +73
-0
lines changed
3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Publish
2
+
3
+ on :
4
+ workflow_dispatch :
5
+
6
+ jobs :
7
+ build :
8
+ timeout-minutes : 45
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - uses : actions/checkout@v2
12
+
13
+ - name : build & publish
14
+ run : scripts/workflow-publish.sh
15
+ env :
16
+ WEB_PATH : build/
17
+ IPFS_API : ${{ secrets.IPFS_API }}
18
+ FLY_ACCESS_TOKEN : ${{ secrets.FLY_ACCESS_TOKEN }}
19
+ DOMAIN : ${{ secrets.DOMAIN }}
Original file line number Diff line number Diff line change
1
+ # /bin/sh
2
+
3
+ set -xe
4
+
5
+ path=$WEB_PATH
6
+ if [ -z $path ]; then
7
+ echo ' path missing'
8
+ exit 1
9
+ fi
10
+
11
+ # init ipfs and calculate CID
12
+ ipfs init
13
+ EXPECTED_CID=$( ipfs --offline add --recursive --hash sha2-256 --cid-version 1 --chunker=size-262144 --only-hash -Q $path | tail -n 1)
14
+
15
+ if [ -z $EXPECTED_CID ]; then
16
+ exit 1
17
+ fi
18
+
19
+ # can't use ipfs because the connection with the ipfs cli to infura doesn't work
20
+ FILES=$( find $path -type f -not -iname " .*" )
21
+ args=' '
22
+ set +x
23
+ for file in $FILES ; do
24
+ filename=${file# " $path " }
25
+ args=" $args -F file=@$file ;filename=_/$filename "
26
+ done
27
+ set -x
28
+ NEW_CID=$( curl $args $IPFS_API ' /api/v0/add?pin=true&cid-version=1&hash=sha2-256&chunker=size-262144' | tail -n 1 | cut -d ' "' -f 8)
29
+
30
+ if [ " $NEW_CID " != " $EXPECTED_CID " ]; then
31
+ exit 1
32
+ fi
33
+
34
+ # update dns
35
+ APEX=` echo ${DOMAIN} | awk -F' .' ' {print $(NF-1)"."$(NF)}' `
36
+ /flyctl dns-records export $APEX > .tmp_zone
37
+ OLD_CID=` dig +short TXT _dnslink.${DOMAIN} | sed -e ' s/dnslink=\/ipfs\///g' -e ' s/"//g' `
38
+ cat .tmp_zone
39
+ sed -i' ' -e " s/$OLD_CID /$NEW_CID /g" .tmp_zone
40
+ cat .tmp_zone
41
+ /flyctl dns-records import $APEX .tmp_zone
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -xe
4
+
5
+ cat | docker build -f - -t tmp ` mktemp -d` << 'EOF '
6
+ FROM flyio/flyctl:v0.0.233 as flyio
7
+ FROM node:lts-alpine
8
+ COPY --from=flyio /flyctl /
9
+ RUN apk add curl bind-tools go-ipfs
10
+ EOF
11
+
12
+ docker run --rm -w /app -v $( pwd) :/app tmp sh -c ' env && yarn && yarn build'
13
+ docker run --rm -w /app -v $( pwd) :/app -e IPFS_API=$IPFS_API -e WEB_PATH=$WEB_PATH -e FLY_ACCESS_TOKEN=$FLY_ACCESS_TOKEN -e DOMAIN=$DOMAIN tmp sh scripts/publish.sh
You can’t perform that action at this time.
0 commit comments