Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/run-nextstrain-open-builds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Run the Nextstrain open builds

defaults:
run:
# This is the same as GitHub Action's `bash` keyword as of 20 June 2023:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
#
# Completely spelling it out here so that GitHub can't change it out from under us
# and we don't have to refer to the docs to know the expected behavior.
shell: bash --noprofile --norc -eo pipefail {0}

on:
# This workflow will be triggered after the "Ingest open" workflow has completed on the "master" branch.
workflow_run:
workflows:
- Ingest open
types:
- completed
branches:
- master

workflow_dispatch:
inputs:
dockerImage:
description: "Specific container image to use for build (will override the default of `nextstrain build`)"
required: false
type: string
trial_name:
description: |
Trial name for deploying builds.
If not set, builds will overwrite existing builds at s3://nextstrain-data/seasonal-flu_open*
If set, builds will be deployed to s3://nextstrain-staging/seasonal-flu_trials_<trial_name>_*
required: false
type: string


jobs:
check-new-data:
if: |
github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.check-cache.outputs.cache-hit }}
steps:
- name: Get sha256sum
id: get-sha256sum
env:
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
run: |
s3_urls=(
"s3://nextstrain-data/files/workflows/seasonal-flu/h1n1pdm/metadata.tsv.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/h1n1pdm/ha/sequences.fasta.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/h1n1pdm/na/sequences.fasta.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/h3n2/metadata.tsv.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/h3n2/ha/sequences.fasta.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/h3n2/na/sequences.fasta.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/vic/metadata.tsv.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/vic/ha/sequences.fasta.zst"
"s3://nextstrain-data/files/workflows/seasonal-flu/vic/na/sequences.fasta.zst"
)

# Code below is modified from ingest/upload-to-s3
# https://github.com/nextstrain/ingest/blob/c0b4c6bb5e6ccbba86374d2c09b42077768aac23/upload-to-s3#L23-L29

no_hash=0000000000000000000000000000000000000000000000000000000000000000

for s3_url in "${s3_urls[@]}"; do
s3path="${s3_url#s3://}"
bucket="${s3path%%/*}"
key="${s3path#*/}"

s3_hash="$(aws s3api head-object --no-sign-request --bucket "$bucket" --key "$key" --query Metadata.sha256sum --output text 2>/dev/null || echo "$no_hash")"
echo "${s3_hash}" | tee -a ingest-open-output-sha256sum
done

- name: Check cache
id: check-cache
uses: actions/cache@v6
with:
path: ingest-open-output-sha256sum
key: ingest-open-output-sha256sum-${{ hashFiles('ingest-open-output-sha256sum') }}
lookup-only: true


run-build:
# Run the workflow under two conditions
# 1. `workflow_run` triggered `check-new-data` and there's new data (no cache hit)
# 2. the workflow is being manually run by `workflow_dispatch`
needs: [check-new-data]
if: |
always() &&
(
(needs.check-new-data.result == 'success' && needs.check-new-data.outputs.cache-hit != 'true') ||
github.event_name == 'workflow_dispatch'
)
permissions:
id-token: write
uses: nextstrain/.github/.github/workflows/pathogen-repo-build.yaml@master
secrets: inherit
with:
runtime: docker
env: |
NEXTSTRAIN_DOCKER_IMAGE: ${{ inputs.dockerImage }}
TRIAL_NAME: ${{ inputs.trial_name }}
run: |
declare -a config

if [[ "$TRIAL_NAME" ]]; then
config+=("deploy_url=s3://nextstrain-staging/seasonal-flu_trials_${TRIAL_NAME}_")
fi

nextstrain build \
. \
deploy_all \
--configfile profiles/nextstrain-open.yaml \
--config "${config[@]}"
Loading