Run script on each mainnet chain #223
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: Run script on each mainnet chain | |
on: | |
schedule: | |
- cron: '35 2 * * *' | |
workflow_dispatch: | |
jobs: | |
run-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ibc-tables repo | |
uses: actions/checkout@v2 | |
- name: Set script permissions | |
run: chmod +x get_ibc_info.sh | |
- name: Run script | |
run: | | |
chains=$(curl -s https://api.github.com/repos/cosmos/chain-registry/contents | jq -r '.[] | select(.type == "dir" and (.name | startswith("_") | not) and (.name | startswith(".") | not) and (.name | startswith("testnets") | not)) | .name' | xargs) | |
echo "$chains" | |
for chain in $chains; do | |
echo "Processing chain: $chain" | |
mkdir -p $chain 2> /dev/null || true | |
if output=$(timeout 1200 ./get_ibc_info.sh https://rest.cosmos.directory/$chain 2> /dev/null); then | |
echo "$output" | |
echo "$output" > $chain/ibc_table.csv.tmp | |
if [ ! -f $chain/ibc_table.csv ] || [ $(wc -l < $chain/ibc_table.csv.tmp) -gt $(wc -l < $chain/ibc_table.csv) ]; then | |
rm -f $chain/ibc_table.csv 2> /dev/null || true | |
mv $chain/ibc_table.csv.tmp $chain/ibc_table.csv | |
echo "++ updated" | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add $chain/ibc_table.csv | |
git commit -m "auto update for $chain" || true | |
git push origin HEAD:main | |
else | |
rm $chain/ibc_table.csv.tmp | |
echo "-- not updated" | |
fi | |
else | |
echo "Script failed for chain: $chain" | |
fi | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_ACTIONS }} |