Skip to content

CronJob

CronJob #5115

Workflow file for this run

name: CronJob
on:
schedule:
- cron: "*/5 * * * *" # every 5 mins
push:
env:
ETHEREUM_GOERLI_RPC_URL: ${{secrets.ETHEREUM_GOERLI_RPC_URL}}
ETHEREUM_SEPOLIA_RPC_URL: ${{secrets.ETHEREUM_SEPOLIA_RPC_URL}}
POLYGON_MUMBAI_RPC_URL: ${{secrets.POLYGON_MUMBAI_RPC_URL}}
jobs:
runCLI:
name: PrizePool Prizes Computation
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
node: ["18.16.0"]
os: [ubuntu-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Dependencies
id: installDependencies
uses: bahmutov/npm-install@v1
with:
install-command: yarn
- name: Install PoolTogether V5 CLI
run: |
npm install -g @pooltogether/[email protected]
echo "$(npm -g bin)" >> $GITHUB_PATH
# -------------------------------------------------------- #
# Mumbai
# -------------------------------------------------------- #
- name: Mumbai Draw Prizes
id: drawPrizesMumbai
uses: chuckbergeron/executable-wrapper@f94b435740d6b958c2d7eb76c77657e761819cfe
continue-on-error: true
with:
run_command: ptv5 compute drawPrizes -o ./prizes -p 0xA32C8f94191c9295634f0034eb2b0e2749e77974 -c 80001
# -------------------------------------------------------- #
# Sepolia
# -------------------------------------------------------- #
- name: Sepolia Draw Prizes
id: drawPrizesSepolia
uses: chuckbergeron/executable-wrapper@f94b435740d6b958c2d7eb76c77657e761819cfe
continue-on-error: true
with:
run_command: ptv5 compute drawPrizes -o ./prizes -p 0xA377A589C1957D7777F6eDF1b7C22C911a56e90F -c 11155111
# -------------------------------------------------------- #
# Comment Error
# -------------------------------------------------------- #
- name: Comment Error
id: commentError
if: steps.drawPrizesMumbai.outputs.exitcode == 1 || steps.drawPrizesSepolia.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 Prizes Failed: Exit Code 1`
})
# -------------------------------------------------------- #
# Git Commit
# TODO: Use actions/github-script@v5 to complete commits
# -------------------------------------------------------- #
- name: Commit Mumbai
if: steps.drawPrizesMumbai.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 ./prizes/80001
git commit -m "Add draw winners for Mumbai - Draw #${{steps.drawPrizesMumbai.outputs.drawId}}"
- name: Commit Sepolia
if: steps.drawPrizesSepolia.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 ./prizes/11155111
git commit -m "Add draw for Sepolia draw #${{steps.drawPrizesSepolia.outputs.drawId}}"
# -------------------------------------------------------- #
# Push Draw Prizes Computation
# -------------------------------------------------------- #
- name: Push changes (if required)
uses: ad-m/github-push-action@master
if: steps.drawPrizesMumbai.outputs.runStatus == 'true' || steps.drawPrizesSepolia.outputs.runStatus == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
force: true