Skip to content

Export

Export #11

Workflow file for this run

name: Export
on:
schedule:
# https://crontab.guru/#05_11_*_*_2
- cron: '05 11 * * 2'
workflow_dispatch:
inputs:
release:
description: 'Ensembl release number (e.g. 104 or latest)'
required: true
default: 'latest'
overwrite:
type: boolean
description: 'Overwrite output on an existing branch.'
default: false
jobs:
export:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
species:
- human
- mouse
- rat
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup dependencies
uses: ./.github/actions/setup
- name: Set parameters
id: params
shell: bash
run: |
DATE_ISO=$(date --utc --iso)
echo "Setting parameter date_iso=$DATE_ISO"
echo "date_iso=$DATE_ISO" >> $GITHUB_OUTPUT
ENSEMBL_RELEASE=${{ github.event.inputs.release || 'latest' }}
ENSEMBL_RELEASE=$(poetry run ensembl_genes ensembl_release --release="$ENSEMBL_RELEASE")
echo "Setting parameter release=$ENSEMBL_RELEASE"
echo "release=$ENSEMBL_RELEASE" >> $GITHUB_OUTPUT
ENSEMBL_DATABASE=$(poetry run ensembl_genes ensembl_database --species="${{ matrix.species }}" --release="$ENSEMBL_RELEASE")
echo "Setting parameter database=$ENSEMBL_DATABASE"
echo "database=$ENSEMBL_DATABASE" >> $GITHUB_OUTPUT
# output_path doubles as a hierarchical branch name
OUTPUT_PATH="output/${ENSEMBL_DATABASE}"
echo "Setting parameter output_path=$OUTPUT_PATH"
echo "output_path=$OUTPUT_PATH" >> $GITHUB_OUTPUT
OUTPUT_EXISTS="true"
git ls-remote --exit-code origin $OUTPUT_PATH || OUTPUT_EXISTS="false"
echo "$OUTPUT_PATH branch exists on origin: $OUTPUT_EXISTS"
echo "output_exists=$OUTPUT_EXISTS" >> $GITHUB_OUTPUT
OVERWRITE=${{ github.event.inputs.overwrite || 'false' }}
echo "Setting parameter overwrite=$OVERWRITE"
echo "overwrite=$OVERWRITE" >> $GITHUB_OUTPUT
EXPORT="false"
if [[ $OUTPUT_EXISTS = "false" || $OVERWRITE = "true" ]]; then
EXPORT="true"
fi
echo "Setting parameter export=$EXPORT"
echo "export=$EXPORT" >> $GITHUB_OUTPUT
- name: Extract tables
id: extract
if: steps.params.outputs.export == 'true'
run: poetry run ensembl_genes all --species="${{ matrix.species }}" --release=${{ steps.params.outputs.release }}
- name: Output artifact
# upload outputs to artifact only when the extraction fails
if: always() && steps.extract.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: failed_output_${{ steps.params.outputs.database }}
path: ${{ steps.params.outputs.output_path }}
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: steps.params.outputs.export == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: ${{ steps.params.outputs.output_path }}
publish_dir: ${{ steps.params.outputs.output_path }}
# Won't actually enable jekyll because we're not using GitHub Pages.
# https://github.com/peaceiris/actions-gh-pages/issues/660
enable_jekyll: true
full_commit_message: |
export ${{ steps.params.outputs.database }} on ${{ steps.params.outputs.date_iso }}
code version ${{ github.sha }}
built by <${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}>
allow_empty_commit: true