Skip to content

Update Asset Registry #493

Update Asset Registry

Update Asset Registry #493

name: Update Asset Registry
on:
schedule:
- cron: '0 20 * * *' # Run daily at 8pm UTC (3pm EST)
workflow_dispatch: # Allow manual triggers
jobs:
update-asset-registry:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Generate and compare tables
env:
STORK_REST_BASE_URL: ${{ secrets.STORK_REST_BASE_URL }}
STORK_AUTH_TOKEN: ${{ secrets.STORK_AUTH_TOKEN }}
run: |
# Create temporary directory for working files
mkdir -p temp
# Generate new asset table
python3 src/scripts/get_asset_table.py > temp/new_asset_table.md
# Extract just the table part from the existing file
sed -n '/| Asset ID/,$p' resources/asset-id-registry.md | sed '/^$/q' > temp/existing_asset_table.md
# Compare the tables
diff_output=$(diff temp/new_asset_table.md temp/existing_asset_table.md || true)
echo "diff_output<<EOF" >> $GITHUB_ENV
echo "$diff_output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Update asset registry file if different
if: env.diff_output != ''
run: |
# Preserve the header of the original file
sed '/| Asset ID/,$d' resources/asset-id-registry.md > temp/temp_file.md
cat temp/new_asset_table.md >> temp/temp_file.md
mv temp/temp_file.md resources/asset-id-registry.md
rm -rf temp
- name: Create Pull Request
if: env.diff_output != ''
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update Asset ID Registry"
title: "Update Asset ID Registry"
body: "Automated update of the Asset ID Registry"
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
branch: update-asset-registry
delete-branch: true
base: main
draft: false