forked from aragon/app
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (90 loc) · 3.73 KB
/
pull_request_webapp_preview.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: Pull Request WebApp Preview
on:
pull_request:
types:
- labeled
- synchronize
jobs:
webapp-preview:
if: contains(github.event.pull_request.labels.*.name, 'preview')
environment: staging
runs-on: ubuntu-latest
steps:
- name: Find a PR comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: 'WebApp IPFS Hash: '
- name: Delete Comment
uses: actions/github-script@v6
continue-on-error: true
if: steps.fc.outputs.comment-id != 0
with:
script: |
github.rest.issues.deleteComment({
comment_id: ${{ steps.fc.outputs.comment-id }},
owner: context.repo.owner,
repo: context.repo.repo,
})
- name: Checkout code
uses: actions/checkout@v3
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install depdendencies
run: yarn install --pure-lockfile
- name: Lint
run: yarn lint
- name: Build
run: yarn build --mode staging
env:
VITE_REACT_APP_DEPLOY_VERSION: ${{ github.sha }}
VITE_REACT_APP_DEPLOY_ENVIRONMENT: ${{ needs.set-environment.outputs.environment }}
VITE_REACT_APP_ANALYTICS_KEY: ${{ secrets.VITE_REACT_APP_ANALYTICS_KEY }}
VITE_IPFS_API_KEY: ${{secrets.VITE_IPFS_API_KEY}}
VITE_ETHERSCAN_API_KEY: ${{secrets.VITE_ETHERSCAN_API_KEY}}
VITE_POLYGONSCAN_API_KEY: ${{secrets.VITE_POLYGONSCAN_API_KEY}}
VITE_GATEWAY_RPC_API_KEY: ${{secrets.VITE_GATEWAY_RPC_API_KEY}}
VITE_WALLET_CONNECT_PROJECT_ID: ${{secrets.VITE_WALLET_CONNECT_PROJECT_ID}}
VITE_ALCHEMY_KEY_POLYGON_MUMBAI: ${{secrets.VITE_ALCHEMY_KEY_POLYGON_MUMBAI}}
VITE_ALCHEMY_KEY_POLYGON_MAINNET: ${{secrets.VITE_ALCHEMY_KEY_POLYGON_MUMBAI}}
VITE_ALCHEMY_KEY_MAINNET: ${{secrets.VITE_ALCHEMY_KEY_MAINNET}}
VITE_ALCHEMY_KEY_GOERLI: ${{secrets.VITE_ALCHEMY_KEY_GOERLI}}
VITE_COVALENT_API_KEY: ${{secrets.VITE_COVALENT_API_KEY}}
NODE_OPTIONS: '--max-old-space-size=6656'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
architecture: 'x64'
- name: Install Python modules
run: |
pip install --user pyyaml packaging
- name: Install ipfs-cluster-ctl
run: |
wget https://dist.ipfs.io/ipfs-cluster-ctl/v1.0.0/ipfs-cluster-ctl_v1.0.0_linux-amd64.tar.gz
tar xvfz ipfs-cluster-ctl_v1.0.0_linux-amd64.tar.gz
- name: Unpin
if: steps.fc.outputs.comment-id != 0
continue-on-error: true
run: |
COMMENT='${{ steps.fc.outputs.comment-body }}'
IFS=" " read -ra array <<< "$COMMENT"
hash=${array[3]}
./ipfs-cluster-ctl/ipfs-cluster-ctl --basic-auth '${{ secrets.IPFS_BASIC_AUTH }}' --host '${{ secrets.IPFS_HOST }}' pin rm $hash
- name: Pin on IPFS
id: ipfsPin
run: |
ipfsResult="$(./ipfs-cluster-ctl/ipfs-cluster-ctl --basic-auth '${{ secrets.IPFS_BASIC_AUTH }}' --host '${{ secrets.IPFS_HOST }}' add -r './dist/' | tail -1)"
IFS=" " read -ra array <<< "$ipfsResult"
echo "ipfsHash=${array[1]}" >> $GITHUB_OUTPUT
- name: Update the PR comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
WebApp IPFS Hash: ${{ steps.ipfsPin.outputs.ipfsHash }}
WebApp deployed to https://ipfs.eth.aragon.network/ipfs/${{ steps.ipfsPin.outputs.ipfsHash }}/