Skip to content

CronJob - Op Mainnet (deprecated) #2192

CronJob - Op Mainnet (deprecated)

CronJob - Op Mainnet (deprecated) #2192

Workflow file for this run

name: CronJob - Op Mainnet (deprecated)
on:
schedule:
- cron: "5 */6 * * *" # ie. 6:05am, 12:05pm, 6:05pm, etc.
push:
env:
FWC_RPC_URL: ${{secrets.OPTIMISM_RPC_URL}}
OPTIMISM_MAINNET_RPC_URL: ${{secrets.OPTIMISM_MAINNET_RPC_URL}}
NODE_OPTIONS: "--max_old_space_size=32768"
permissions: write-all
jobs:
runCLI:
name: Winners Compute
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
node: ["20.11.1"]
os: [ubuntu-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Clone foundry-winner-calc repo
uses: actions/checkout@master
with:
repository: GenerationSoftware/foundry-winner-calc
path: './foundry-winner-calc'
# -------------------------------------------------------- #
# Optimism
# -------------------------------------------------------- #
# 1. Install
- name: Install PoolTogether V5 CLI
run: |
npm install -g @generationsoftware/[email protected]
echo "$(npm -g bin)" >> $GITHUB_PATH
# 2. Compute JSON input files (vault accounts)
- name: Optimism Vault Accounts
id: vaultAccountsOptimism
uses: chuckbergeron/executable-wrapper@e19cd743c8f0c6af006f6a25bd6715c770569d72
continue-on-error: true
with:
working-directory: ./foundry-winner-calc
run_command: ptv5 compute vaultAccounts -o ./vaultAccounts -p 0xe32e5E1c5f0c80bD26Def2d0EA5008C107000d6A -c 10
# 3. Install package deps, build contracts
- name: Install deps and compile
run: |
cd ./foundry-winner-calc
npm install
npm run build
cd sol
forge install
forge build
cd ..
# 4. Store list of input JSON files in variable
- name: Finding files
working-directory: ./foundry-winner-calc
run: |
{
echo 'FILELIST<<EOF'
find ./vaultAccounts -type f -name '0x*.json' -print
echo EOF
} >> "$GITHUB_ENV"
# 5. Loop through vault input files, compute winners
- name: Iterate vaults
id: processVaults
working-directory: ./foundry-winner-calc
run: |
for i in $FILELIST; do
echo "Processing: ${i}"
node index.js ${i} ../winners/${i}
done
# 6. Concat winner output files into 1 winners.json file
- name: Concat Winner Files
uses: chuckbergeron/executable-wrapper@e19cd743c8f0c6af006f6a25bd6715c770569d72
continue-on-error: true
with:
working-directory: ./winners
run_command: ptv5 utils concatWinners -o ./vaultAccounts -p 0xe32e5E1c5f0c80bD26Def2d0EA5008C107000d6A -c 10
# 7. Commit
- name: Commit Optimism
if: steps.vaultAccountsOptimism.outputs.runStatus == 'true'
continue-on-error: true
run: |
git config pull.rebase false
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 ./winners
git commit -m "Add mainnet (deprecated) winner results for Optimism draw #${{steps.vaultAccountsOptimism.outputs.drawId}}"
# 8. Push
- name: Push changes (if required)
uses: ad-m/github-push-action@master
if: steps.vaultAccountsOptimism.outputs.runStatus == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
force: true