Deploy private.nextflu.org #81
This file contains 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: Deploy private.nextflu.org | |
on: | |
workflow_dispatch: | |
inputs: | |
aws_batch_job_id: | |
description: The AWS Batch Job ID for the private nextflu seasonal flu builds. | |
type: string | |
required: true | |
deploy_to_staging: | |
description: Deploy to the staging website at https://staging-private-nextflu.netlify.app | |
type: boolean | |
required: true | |
env: | |
# Everything should run from within the nextflu/auspice directory | |
# https://github.com/blab/nextflu/tree/e672eba6d2e0ad5e10b0775f94fc87ffc75d6005/auspice | |
WORKING_DIR: auspice | |
AUSPICE_DIR: auspice-who | |
defaults: | |
run: | |
# Cannot use contexts or expressions for this top level defaults, so must | |
# hard-code the path instead of using env.WORKING_DIR | |
# https://docs.github.com/en/actions/using-jobs/setting-default-values-for-jobs#setting-default-shell-and-working-directory | |
working-directory: auspice | |
jobs: | |
deploy_to_netlify: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: blab/nextflu | |
sparse-checkout: | | |
${{ env.WORKING_DIR }} | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.3.7' | |
bundler-cache: true | |
# `uses` does not respect the default working-directory | |
# Luckily, the setup-ruby action has a `working-directory` input | |
# https://github.com/ruby/setup-ruby#working-directory | |
# | |
# Must be set to access the Gemfile.lock file in the auspice directory | |
# https://github.com/blab/nextflu/blob/12c5645d990f53c553d6f04e293e2f12b4ad3575/auspice/Gemfile.lock | |
working-directory: ${{ env.WORKING_DIR }} | |
- name: Configure credentials for GitHub Actions job access to AWS Batch | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-1 | |
role-to-assume: arn:aws:iam::827581582529:role/GitHubActionsRoleNextstrainBatchJobs | |
- uses: nextstrain/.github/actions/setup-nextstrain-cli@master | |
- name: Download builds from AWS Batch | |
run: | | |
nextstrain build \ | |
--aws-batch \ | |
--attach "$AWS_BATCH_JOB_ID" \ | |
--download "$AUSPICE_DIR/*.json" \ | |
--no-logs \ | |
. | |
env: | |
AWS_BATCH_JOB_ID: ${{ inputs.aws_batch_job_id }} | |
- name: Move Auspice JSONs | |
run: | | |
mkdir data | |
mv "$AUSPICE_DIR"/*.json data/ | |
rm -r "$AUSPICE_DIR" | |
- name: Create index files | |
run: python provision_directories.py | |
- name: Build site | |
run: bundle exec jekyll build | |
- uses: actions/setup-node@v4 | |
with: | |
# Minimum node version to install Netlify CLI | |
# https://docs.netlify.com/cli/get-started/#installation | |
node-version: 18 | |
- name: Install Netlify CLI | |
run: npm install [email protected] -g | |
- name: Deploy to Netlify | |
run: netlify deploy --build --prod | |
env: | |
NETLIFY_SITE_ID: ${{ inputs.deploy_to_staging && secrets.NETLIFY_SITE_ID_STAGING || secrets.NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |