Update Permit Info #37
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: 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, 100, 8453, 42161] # all supported chains | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up node | |
uses: actions/setup-node@v3 | |
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" | |
run: | | |
IFS=',' read -r -a TOKEN_LIST_ARRAY <<< "${{ env.TOKEN_LISTS }}" | |
for TOKEN_LIST in "${TOKEN_LIST_ARRAY[@]}"; do | |
if [ -f "$TOKEN_LIST" ]; then | |
yarn fetchPermitInfo -- ${{ matrix.chainId }} `pwd`/$TOKEN_LIST ${{ env.RPC_URL }} | |
fi | |
done | |
- name: Upload File | |
uses: actions/upload-artifact@v4 | |
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@v3 | |
- name: Download all | |
uses: actions/download-artifact@v4 | |
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' }} | |
run: | | |
git commit -m "chore: automated permit info update" | |
git push origin main | |
handle-failure: | |
needs: update-permit-info | |
if: failure() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create issue on failure | |
uses: actions/github-script@v6 | |
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}` | |
}) |