[bot] [DO NOT MERGE] Test Auspice PR 1763 #1104
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
static-site-lint: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: static-site/ | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '16' | |
- run: npm ci | |
- run: npm run lint | |
test: | |
if: github.repository == 'nextstrain/nextstrain.org' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '16' | |
- run: node --version | |
- run: npm ci | |
- run: npm run build | |
- run: npm run lint | |
# configure AWS to run dev server necessary for `npm run test:ci` | |
- uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
aws-access-key-id: ${{ secrets.DEV_SERVER_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.DEV_SERVER_AWS_SECRET_ACCESS_KEY }} | |
- run: aws sts get-caller-identity | |
- run: npm run test:ci | |
- if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logs | |
path: test/server.log | |
# XXX TODO: It'd be nice to avoid the rebuild on Heroku and instead deploy | |
# the artifacts (source code + generated files + node_modules/) already built | |
# above. This would dramatically reduce deploy times and move us closer to | |
# "deploy what you tested", but it may also run into platform compatibility | |
# issues given CI is building on a different platform (arch + OS + sys libs) | |
# than Heroku's dynos and some deps are compiled. But should try it and see! | |
# Or do our build above inside a Heroku buildpack… | |
# -trs, 2 May 2022 | |
deploy: | |
if: |2 | |
github.repository == 'nextstrain/nextstrain.org' | |
&& github.event_name == 'push' | |
&& github.ref == 'refs/heads/master' | |
# Wait for "test" job above to pass. | |
needs: test | |
# Only one "deploy" job at a time. | |
concurrency: deploy | |
# Name a GitHub environment configuration¹ to auto-create deployment | |
# records in GitHub based on this job's progress/status. Also grants | |
# access to environment-specific secrets. | |
# | |
# The URL is specific to this deployment, not the environment (i.e. an | |
# environment have deployments at different URLs). | |
# | |
# ¹ https://github.com/nextstrain/nextstrain.org/settings/environments | |
environment: | |
name: heroku | |
url: https://next.nextstrain.org | |
# Deploy steps | |
runs-on: ubuntu-latest | |
env: | |
HEROKU_APP: nextstrain-canary | |
steps: | |
- name: Login to Heroku | |
run: echo "machine api.heroku.com login $HEROKU_USER password $HEROKU_TOKEN" >> ~/.netrc | |
env: | |
HEROKU_USER: "${{ secrets.HEROKU_USER }}" | |
HEROKU_TOKEN: "${{ secrets.HEROKU_TOKEN }}" | |
- name: Define Heroku build source | |
run: | | |
jq --null-input '{ | |
"source_blob": { | |
"url": "https://github.com/\(env.GITHUB_REPOSITORY)/archive/\(env.GITHUB_SHA).tar.gz", | |
"version": env.GITHUB_SHA | |
} | |
}' | tee build-source.json | |
- name: Start Heroku build | |
run: | | |
curl https://api.heroku.com/apps/"$HEROKU_APP"/builds \ | |
--fail --silent --show-error --location --netrc \ | |
--data-binary @build-source.json \ | |
--header 'Content-Type: application/json' \ | |
--header 'Accept: application/vnd.heroku+json; version=3' \ | |
| tee build.json | |
- name: Monitor Heroku build | |
run: | | |
curl "$(jq -r .output_stream_url build.json)" \ | |
--fail --silent --show-error --location | |
- name: Check Heroku build | |
run: | | |
id="$(jq -r .id build.json)" | |
SECONDS=0 | |
maxwait=60 | |
while [[ $SECONDS -lt $maxwait ]]; do | |
curl https://api.heroku.com/apps/"$HEROKU_APP"/builds/"$id" \ | |
--fail --silent --show-error --location --netrc \ | |
--header 'Accept: application/vnd.heroku+json; version=3' \ | |
| tee build.json | |
status="$(jq -r .status build.json)" | |
if [[ "$status" == succeeded ]]; then | |
break | |
else | |
echo "build status is $status (not succeeded); will check again" >&2 | |
sleep 5 | |
fi | |
done | |
if [[ "$status" != succeeded ]]; then | |
echo "build status is $status (not succeeded) after waiting $SECONDS seconds" >&2 | |
exit 1 | |
fi | |
- if: always() | |
name: Logout of Heroku | |
run: sed -i -e '/^machine api\.heroku\.com/d' ~/.netrc |