Skip to content

Update Permit Info #287

Update Permit Info

Update Permit Info #287

name: Update Permit Info
on:
# Run after generateAuxLists workflow completes
workflow_run:
workflows: ["Generate Auxiliary Lists"]
types:
- completed
# Allow manual trigger
workflow_dispatch:
jobs:
update-permit-info:
name: Update permit info
runs-on: ubuntu-latest
strategy:
fail-fast: false # continue parallel jobs even if individual parts fail
matrix:
chainId: [ 1, 56, 100, 137, 232, 8453, 42161, 43114 ] # all supported chains
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: lts/*
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Generate Permit Info
env:
RPC_URL: ${{ secrets[format('RPC_URL_{0}', matrix.chainId)] }}
TOKEN_LISTS: "src/public/CowSwap.json,src/public/Uniswap.${{ matrix.chainId }}.json,src/public/CoinGecko.${{ matrix.chainId }}.json"
CHAIN_ID: ${{ matrix.chainId }}
run: |
IFS=',' read -r -a TOKEN_LIST_ARRAY <<< $TOKEN_LISTS
for TOKEN_LIST in "${TOKEN_LIST_ARRAY[@]}"; do
if [ -f "$TOKEN_LIST" ]; then
yarn fetchPermitInfo -- $CHAIN_ID `pwd`/$TOKEN_LIST $RPC_URL
fi
done
- name: Upload File
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ format('PermitInfo.{0}.json', matrix.chainId) }}
path: src/public/${{ format('PermitInfo.{0}.json', matrix.chainId) }}
retention-days: 1
commit-changes:
needs: update-permit-info
if: success()
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Download all
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: src/public/
merge-multiple: true
- name: Check for changes
id: git-check
run: |
git add src/public/PermitInfo.*.json
if git status --porcelain | grep "src/public/PermitInfo.*\.json$"; then
echo "no_changes=false" >> $GITHUB_OUTPUT
else
echo "no_changes=true" >> $GITHUB_OUTPUT
fi
- name: Configure Git
if: ${{ steps.git-check.outputs.no_changes == 'false' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Commit and push changes
if: ${{ steps.git-check.outputs.no_changes == 'false' }}
env:
BRANCH: ${{ github.ref_name }}
run: |
git commit -m "chore: automated permit info update"
git push origin $BRANCH
handle-failure:
needs: update-permit-info
if: failure()
runs-on: ubuntu-latest
steps:
- name: Create issue on failure
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Permit Info Update Failed',
body: `The workflow to update permit info failed on ${new Date().toISOString()}.
Please check the workflow logs for more details: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
})