-
Notifications
You must be signed in to change notification settings - Fork 6
126 lines (126 loc) · 6.06 KB
/
cron.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: CronJob
on:
schedule:
- cron: "0 20,21 * * *" # everyday at 8pm and 9 pm UTC
push:
env:
ETHEREUM_MAINNET_RPC_URL: ${{secrets.ETHEREUM_MAINNET_RPC_URL}}
POLYGON_MAINNET_RPC_URL: ${{secrets.POLYGON_MAINNET_RPC_URL}}
AVALANCHE_MAINNET_RPC_URL: ${{secrets.AVALANCHE_MAINNET_RPC_URL}}
OPTIMISM_MAINNET_RPC_URL: ${{secrets.OPTIMISM_MAINNET_RPC_URL}}
ETHEREUM_RINKEBY_RPC_URL: ${{secrets.ETHEREUM_RINKEBY_RPC_URL}}
POLYGON_MUMBAI_RPC_URL: ${{secrets.POLYGON_MUMBAI_RPC_URL}}
AVALANCHE_FUJI_RPC_URL: ${{secrets.AVALANCHE_FUJI_RPC_URL}}
OPTIMISM_KOVAN_RPC_URL: ${{secrets.OPTIMISM_KOVAN_RPC_URL}}
DEBUG: ${{secrets.DEBUG}}
jobs:
runCLI:
name: PrizePoolNetwork Prizes Computation
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
node: ["16.9.0"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Yarn
run: npm install -g yarn
- name: Run Yarn
run: yarn
# -------------------------------------------------------- #
# Ethereum Mainnet (USDC)
# -------------------------------------------------------- #
- name: Ethereum Draw Prizes
id: drawPrizesEthereumMainnet
continue-on-error: true
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0xdd4d117723C257CEe402285D3aCF218E9A8236E1 -c 1
# -------------------------------------------------------- #
# Polygon Mainnet (USDC)
# -------------------------------------------------------- #
- name: Polygon Draw Prizes
id: drawPrizesPolygonMainnet
continue-on-error: true
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076 -c 137
# -------------------------------------------------------- #
# Avalanche Mainnet (USDC)
# -------------------------------------------------------- #
- name: Avalanche Draw Prizes
id: drawPrizesAvalancheMainnet
continue-on-error: true
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0xB27f379C050f6eD0973A01667458af6eCeBc1d90 -c 43114
# -------------------------------------------------------- #
# Optimism Mainnet (USDC)
# -------------------------------------------------------- #
- name: Optimism Draw Prizes
id: drawPrizesOptimismMainnet
continue-on-error: true
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0x62BB4fc73094c83B5e952C2180B23fA7054954c4 -c 10
# -------------------------------------------------------- #
# Comment Error
# -------------------------------------------------------- #
- name: Comment Error
id: commentError
if: steps.drawPrizesEthereumMainnet.outputs.exitcode == 1 || steps.drawPrizesPolygonMainnet.outputs.exitcode == 1 || steps.drawPrizesAvalancheMainnet.outputs.exitcode == 1 || steps.drawPrizesOptimismMainnet.outputs.exitcode == 1
uses: actions/github-script@v5
continue-on-error: true
with:
script: |
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Draw Calculator Failed: Exit Code ${process.env.exitCode} (${process.env.errorcode})`
})
# -------------------------------------------------------- #
# Git Commit
# TODO: Use actions/github-script@v5 to complete commits
# -------------------------------------------------------- #
- name: Commit Ethereum
if: steps.drawPrizesEthereumMainnet.outputs.runStatus == 'true'
continue-on-error: true
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add ./api/prizes/1/
git commit -m "Add draw for mainnet draw ${{steps.drawPrizesEthereumMainnet.outputs.drawIds}}"
- name: Commit Polygon
if: steps.drawPrizesPolygonMainnet.outputs.runStatus == 'true'
continue-on-error: true
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add ./api/prizes/137/
git commit -m "Add draw for polygon draw ${{steps.drawPrizesPolygonMainnet.outputs.drawIds}}"
- name: Commit Avalanche
if: steps.drawPrizesAvalancheMainnet.outputs.runStatus == 'true'
continue-on-error: true
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add ./api/prizes/43114/
git commit -m "Add draw for avalanche draw ${{steps.drawPrizesAvalancheMainnet.outputs.drawIds}}"
- name: Commit Optimism
if: steps.drawPrizesOptimismMainnet.outputs.runStatus == 'true'
continue-on-error: true
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add ./api/prizes/10/
git commit -m "Add draw for optimism draw ${{steps.drawPrizesOptimismMainnet.outputs.drawIds}}"
# -------------------------------------------------------- #
# Push Draw Prizes Computation
# -------------------------------------------------------- #
- name: Push changes (if required)
uses: ad-m/github-push-action@master
if: steps.drawPrizesEthereumMainnet.outputs.runStatus == 'true' || steps.drawPrizesPolygonMainnet.outputs.runStatus == 'true' || steps.drawPrizesAvalancheMainnet.outputs.runStatus == 'true' || steps.drawPrizesOptimismMainnet.outputs.runStatus == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}