Compare Upstream #408
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: Compare Upstream | |
on: | |
schedule: | |
- cron: "15 2 * * *" # 2:15am UTC every day | |
workflow_dispatch: | |
jobs: | |
compare: | |
runs-on: ubuntu-latest | |
outputs: | |
upstream_change: ${{ steps.compare_step.outputs.upstream_change }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Upgrade pip and install requests | |
run: python -m pip install --upgrade build requests | |
- name: Get mpc_obscodes from PyPI and Extract obscodes_extended.json | |
# Download the contents of the PyPI package to the `remote` folder | |
# Extract the file we want to md5 compare and store it in `remote/obscodes_extended.json` | |
run: | | |
pip download --no-binary :all: -d remote mpc-obscodes | |
tar -zxf remote/* --wildcards --no-anchored '*obscodes_extended.json' -O > remote/obscodes_extended.json | |
- name: Download and Decompress the MPC Observatory Code File | |
# Fetch the new files we care about and stick them in `new` | |
run: | | |
mkdir new | |
python mpc_obscodes/fetch.py --compressed_file new/obscodes_extended.json.gz --decompressed_file new/obscodes_extended.json --md5_file new/obscodes_extended.md5 | |
- name: Detect Changes to obscodes_extended.json | |
# Compare the md5s of the two files and indicate upstream change in the output | |
id: compare_step | |
run: | | |
python mpc_obscodes/compare.py remote/obscodes_extended.json new/obscodes_extended.json && echo 'upstream_change=false' >> $GITHUB_OUTPUT || echo 'upstream_change=true' >> $GITHUB_OUTPUT | |
build-test-publish: | |
needs: compare | |
if: needs.compare.outputs.upstream_change == 'true' | |
uses: B612-Asteroid-Institute/mpc_obscodes/.github/workflows/build_test_publish.yml@main |