Skip to content

CronJob

CronJob #2219

Workflow file for this run

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 }}