Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github action for updating archives list #107

Merged
merged 11 commits into from
Oct 16, 2024
46 changes: 46 additions & 0 deletions .github/workflows/update-archives-list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: update-archives-list-pr
run-name: Updating archives list
on:
workflow_dispatch:
push:
schedule:
- cron: '0 0 * * 0'
jobs:
run-archive-script:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: install python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: install pyvo and required dependencies
run: |
python -m ensurepip --upgrade
pip install astropy
pip install requests
pip install pyvo

- name: create temp PR branch
run: |
DATE=$(date +'%Y%m%d')
BRANCH_NAME="archives-update-pr-${DATE}"
git checkout -b $BRANCH_NAME
git push origin $BRANCH_NAME

- name: run archives script
run: python fetch_archives.py

- name: List files after script execution
run: ls -la

- name: create pull request
run: |
DATE=$(date +'%Y%m%d')
BRANCH_NAME="archives-update-pr-${DATE}"
gh pr create -B main -H $BRANCH_NAME --title 'Archives list update' --body 'Automated pull request for archives list update'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions fetch_archives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pyvo


def fetch_archives():
archive_list = pyvo.registry.search(servicetype="tap")

with open('tools/archives/pyvo_integration/tool-data/astronomical_archives_gen.loc', 'w') as f, open('tools/archives/pyvo_integration/tool-data/astronomical_archives_gen.loc.sample', 'w') as f1:

table_description = '#Table used for listing astronomical archives TAP service urls\n'
column_description = '#<id>\t<display_name>\t<value>\n'

f.write(table_description)
f.write(column_description)

f1.write(table_description)
f1.write(column_description)

for i, archive in enumerate(archive_list):
try:
archive_name = archive.res_title
access_url = archive.access_url
f.write(f'{i}\t{archive_name}\t{access_url}\n')
f1.write(f'{i}\t{archive_name}\t{access_url}\n')
except Exception as e:
pass


if __name__ == '__main__':
fetch_archives()

Loading