-
Notifications
You must be signed in to change notification settings - Fork 25
90 lines (76 loc) · 2.77 KB
/
nixbuild-n-ipfsdeploy.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
name: deploy-to-ipfs
on: workflow_dispatch
jobs:
nix-build:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: install Nix
uses: cachix/install-nix-action@v16
- uses: cachix/cachix-action@v8
with:
name: centrifuge-website
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: build
id: build
run: |
nix build -L .
echo "::set-output name=dist::$(readlink result)"
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: centrifuge-website-${{ github.sha }}
path: ${{ steps.build.outputs.dist }}
publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
needs: build
steps:
- name: download artifact
uses: actions/download-artifact@v2
with:
name: centrifuge-website-${{ github.sha }}
path: centrifuge-website
- uses: ipfs/download-ipfs-distribution-action@v1
- name: initialize ipfs configuration
run: ipfs init --profile server
# See https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#autorelay
- run: ipfs config --json Swarm.RelayClient.Enabled true
- uses: ipfs/start-ipfs-daemon-action@v1
with:
args: '' # skip config init because we already did it above
- name: publish the website on ipfs
id: publish
run: |
ipfs add -rQ centrifuge-website | tee ipfs_cid
echo "::set-output name=cid::$(cat ipfs_cid)"
- name: pin the website using pinata
run: |
ipfs pin remote service add pinata https://api.pinata.cloud/psa ${{ secrets.PINATA_JWT }}
cid=${{ steps.publish.outputs.cid }}
if ! ipfs pin remote ls --service=pinata --cid=$cid | grep pinned; then
ipfs pin remote add --service=pinata --name=centrifuge-website $cid
fi
comment-on-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: build
steps:
- uses: jwalton/gh-find-current-pr@v1
id: finder
- uses: marocchino/[email protected]
with:
number: ${{ steps.finder.outputs.pr }}
hide_and_recreate: true
hide_classify: 'OUTDATED'
message: |
<h2 align="center">IPFS Preview for ${{ github.sha }} is ready</h2>
<p align="center">
<a href="https://ipfs.io/ipfs/${{ steps.publish.outputs.cid }}/" target="_blank">
<code>${{ steps.publish.outputs.cid }}</code>
:mag_right:
</a>
</p>