Export and Publish Taxonomy #2027
This file contains hidden or 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: Export and Publish Taxonomy | |
| permissions: write-all | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| jobs: | |
| export_publish: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [ '3.10' ] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
| fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
| - name: Set up Python environment | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install tdta cas-tools | |
| - name: Identify JSON file and Taxonomy ID | |
| id: set_vars | |
| run: | | |
| set -e | |
| # Locate the first JSON file found in the root directory | |
| cas_json_file=$(ls *.json 2>/dev/null | head -n 1) | |
| if [ -z "$cas_json_file" ]; then | |
| echo "No JSON file found in the repository root." >&2 | |
| exit 1 | |
| fi | |
| taxonomy_id=$(basename "$cas_json_file" .json) | |
| echo "cas_json_file=$cas_json_file" >> $GITHUB_OUTPUT | |
| echo "taxonomy_id=$taxonomy_id" >> $GITHUB_OUTPUT | |
| echo "Found JSON file: $cas_json_file with taxonomy_id: $taxonomy_id" | |
| - name: Run tdta export | |
| run: | | |
| tdta export -f ./curation_tables -o "${{ steps.set_vars.outputs.cas_json_file }}" -c ./ | |
| - name: Run cas2rdf conversion | |
| run: | | |
| cas cas2rdf --schema bican \ | |
| --data "${{ steps.set_vars.outputs.cas_json_file }}" \ | |
| --ontology_ns "${{ steps.set_vars.outputs.taxonomy_id }}" \ | |
| --ontology_iri "https://purl.brain-bican.org/ontology/${{ steps.set_vars.outputs.taxonomy_id }}/" \ | |
| --out "${{ steps.set_vars.outputs.taxonomy_id }}.rdf" \ | |
| --exclude_cells | |
| - name: Commit and push changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add "${{ steps.set_vars.outputs.cas_json_file }}" "${{ steps.set_vars.outputs.taxonomy_id }}.rdf" | |
| git diff --quiet && git diff --staged --quiet || git commit -a -m "Build CAS Json and RDF files." | |
| - name: Push changes | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{secrets.TDT_TOKEN}} | |
| branch: ${{ github.head_ref }} |