CronJob Testnet #7423
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CronJob Testnet | |
on: | |
schedule: | |
- cron: "0 */4 * * *" # every 4 hours | |
push: | |
env: | |
ETHEREUM_GOERLI_RPC_URL: ${{secrets.ETHEREUM_GOERLI_RPC_URL}} | |
OPTIMISM_GOERLI_RPC_URL: ${{secrets.OPTIMISM_GOERLI_RPC_URL}} | |
ARBITRUM_GOERLI_RPC_URL: ${{secrets.ARBITRUM_GOERLI_RPC_URL}} | |
DEBUG: ${{secrets.DEBUG}} | |
jobs: | |
runCLI: | |
name: Testnet 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 Goerli (USDC) | |
# -------------------------------------------------------- # | |
- name: Ethereum Goerli Draw Prizes | |
id: drawPrizesEthereumGoerli | |
continue-on-error: true | |
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0x8537C5a9AAd3ec1D31a84e94d19FcFC681E83ED0 -c 5 | |
# -------------------------------------------------------- # | |
# Optimism Goerli (USDC) | |
# -------------------------------------------------------- # | |
- name: Optimism Goerli Draw Prizes | |
id: drawPrizesOptimismGoerli | |
continue-on-error: true | |
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0x8537C5a9AAd3ec1D31a84e94d19FcFC681E83ED0 -c 420 | |
# -------------------------------------------------------- # | |
# Arbitrum Goerli (USDC) | |
# -------------------------------------------------------- # | |
- name: Arbitrum Goerli Draw Prizes | |
id: drawPrizesArbitrumGoerli | |
continue-on-error: true | |
run: node_modules/.bin/ptv4 compute poolPrizes -o ./api/prizes -t 0x8739Da6c93D0CE6F5de9D2d71493fAF012F2bDbD -c 421613 | |
# -------------------------------------------------------- # | |
# Comment Error | |
# -------------------------------------------------------- # | |
- name: Comment Error | |
id: commentError | |
if: steps.drawPrizesEthereumGoerli.outputs.exitcode == 1 || steps.drawPrizesOptimismGoerli.outputs.exitcode == 1 || steps.drawPrizesArbitrumGoerli.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 Goerli | |
if: steps.drawPrizesEthereumGoerli.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/5/ | |
git commit -m "Add draw for Ethereum Goerli draw ${{steps.drawPrizesEthereumGoerli.outputs.drawIds}}" | |
- name: Commit Optimism Goerli | |
if: steps.drawPrizesOptimismGoerli.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/420/ | |
git commit -m "Add draw for Optimism Goerli draw ${{steps.drawPrizesOptimismGoerli.outputs.drawIds}}" | |
- name: Commit Arbitrum Goerli | |
if: steps.drawPrizesArbitrumGoerli.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/421613/ | |
git commit -m "Add draw for Arbitrum Goerli draw ${{steps.drawPrizesArbitrumGoerli.outputs.drawIds}}" | |
# -------------------------------------------------------- # | |
# Push Draw Prizes Computation | |
# -------------------------------------------------------- # | |
- name: Push changes (if required) | |
uses: ad-m/github-push-action@master | |
if: steps.drawPrizesEthereumGoerli.outputs.runStatus == 'true' || steps.drawPrizesOptimismGoerli.outputs.runStatus == 'true' || steps.drawPrizesArbitrumGoerli.outputs.runStatus == 'true' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |