Skip to content

Commit 37b6c7c

Browse files
authored
.github/nextstrain-open: Add workflow_run trigger
Automatically trigger the workflow if "Ingest open" successfully completes. Checks for new data for each subtype based on the metadata and HA/NA FASTA files.
1 parent 9311991 commit 37b6c7c

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/run-nextstrain-open-builds.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ defaults:
1010
shell: bash --noprofile --norc -eo pipefail {0}
1111

1212
on:
13+
# This workflow will be triggered after the "Ingest open" workflow has completed on the "master" branch.
14+
workflow_run:
15+
workflows:
16+
- Ingest open
17+
types:
18+
- completed
19+
branches:
20+
- master
21+
1322
workflow_dispatch:
1423
inputs:
1524
dockerImage:
@@ -18,7 +27,65 @@ on:
1827
type: string
1928

2029
jobs:
30+
check-new-data:
31+
if: |
32+
github.event_name == 'workflow_run' &&
33+
github.event.workflow_run.conclusion == 'success'
34+
runs-on: ubuntu-latest
35+
outputs:
36+
cache-hit: ${{ steps.check-cache.outputs.cache-hit }}
37+
steps:
38+
- name: Get sha256sum
39+
id: get-sha256sum
40+
env:
41+
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
42+
run: |
43+
s3_urls=(
44+
"s3://nextstrain-data/files/workflows/seasonal-flu/h1n1pdm/metadata.tsv.zst"
45+
"s3://nextstrain-data/files/workflows/seasonal-flu/h1n1pdm/ha/sequences.fasta.zst"
46+
"s3://nextstrain-data/files/workflows/seasonal-flu/h1n1pdm/na/sequences.fasta.zst"
47+
"s3://nextstrain-data/files/workflows/seasonal-flu/h3n2/metadata.tsv.zst"
48+
"s3://nextstrain-data/files/workflows/seasonal-flu/h3n2/ha/sequences.fasta.zst"
49+
"s3://nextstrain-data/files/workflows/seasonal-flu/h3n2/na/sequences.fasta.zst"
50+
"s3://nextstrain-data/files/workflows/seasonal-flu/vic/metadata.tsv.zst"
51+
"s3://nextstrain-data/files/workflows/seasonal-flu/vic/ha/sequences.fasta.zst"
52+
"s3://nextstrain-data/files/workflows/seasonal-flu/vic/na/sequences.fasta.zst"
53+
)
54+
55+
# Code below is modified from ingest/upload-to-s3
56+
# https://github.com/nextstrain/ingest/blob/c0b4c6bb5e6ccbba86374d2c09b42077768aac23/upload-to-s3#L23-L29
57+
58+
no_hash=0000000000000000000000000000000000000000000000000000000000000000
59+
60+
for s3_url in "${s3_urls[@]}"; do
61+
s3path="${s3_url#s3://}"
62+
bucket="${s3path%%/*}"
63+
key="${s3path#*/}"
64+
65+
s3_hash="$(aws s3api head-object --no-sign-request --bucket "$bucket" --key "$key" --query Metadata.sha256sum --output text 2>/dev/null || echo "$no_hash")"
66+
echo "${s3_hash}" | tee -a ingest-open-output-sha256sum
67+
done
68+
69+
- name: Check cache
70+
id: check-cache
71+
uses: actions/cache@v6
72+
with:
73+
path: ingest-open-output-sha256sum
74+
key: ingest-open-output-sha256sum-${{ hashFiles('ingest-open-output-sha256sum') }}
75+
lookup-only: true
76+
77+
2178
run-build:
79+
# Run the workflow under two conditions
80+
# 1. `workflow_run` triggered `check-new-data` and there's new data (no cache hit)
81+
# 2. the workflow is being manually run by `workflow_dispatch`
82+
needs: [check-new-data]
83+
if: |
84+
always() &&
85+
(
86+
(needs.check-new-data.result == 'success' && needs.check-new-data.outputs.cache-hit != 'true') ||
87+
github.event_name == 'workflow_dispatch'
88+
)
2289
permissions:
2390
id-token: write
2491
uses: nextstrain/.github/.github/workflows/pathogen-repo-build.yaml@master

0 commit comments

Comments
 (0)