Skip to content
Closed
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions .github/workflows/remove-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy PR previews
concurrency: preview-${{ github.ref }}
on:
pull_request:
types:
- closed
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rossjrw/pr-preview-action@v1
with:
source-dir: "preview-build"
preview-branch: "gh-pages"
action: remove
58 changes: 43 additions & 15 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ jobs:
fetch-depth: 1
submodules: true

- name: "Set PR_NUMBER for preview builds"
if: github.event_name == 'pull_request'
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: "Get docker build checksum"
id: docker-build-checksum
run: echo "checksum=$(./scripts/docker_build_checksum.sh)" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -148,17 +152,19 @@ jobs:
cp .env.example .env
sed -i -e "s|FULL_DOMAIN=autodetect|FULL_DOMAIN=${FULL_DOMAIN}|g" .env
sed -i -e "s|DATA_FULL_DOMAIN=https://data.master.clades.nextstrain.org/v3|DATA_FULL_DOMAIN=${DATA_FULL_DOMAIN}|g" .env
# include PR_NUMBER for preview builds in .env
if [ -n "${PR_NUMBER:-}" ]; then echo "PR_NUMBER=${PR_NUMBER}" >> .env; fi

- name: "Login to Docker Hub"
uses: docker/login-action@v3
with:
registry: docker.io
username: nextstrainbot
password: ${{ secrets.DOCKER_TOKEN }}
# - name: "Login to Docker Hub"
# uses: docker/login-action@v3
# with:
# registry: docker.io
# username: nextstrainbot
# password: ${{ secrets.DOCKER_TOKEN }}

- name: "Build docker image"
run: |
CROSS="wasm32-unknown-unknown" ./docker/dev docker-image-build-push
# - name: "Build docker image"
# run: |
# CROSS="wasm32-unknown-unknown" ./docker/dev docker-image-build-push

- name: "Install Node.js packages"
run: |
Expand All @@ -172,13 +178,13 @@ jobs:
run: |
./docker/dev web-release

- name: "Lint web app code"
run: |
./docker/dev web yarn lint:ci
# - name: "Lint web app code"
# run: |
# ./docker/dev web yarn lint:ci

- name: "Lint Rust code"
run: |
./docker/dev lint-ci
# - name: "Lint Rust code"
# run: |
# ./docker/dev lint-ci

- name: "Upload build artifacts"
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -269,3 +275,25 @@ jobs:

git tag "web-${version}"
git push origin "web-${version}"

deploy-preview:
name: "Deploy PR Preview"
if: github.event_name == 'pull_request'
needs: [ build-web ]
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Download build artifacts"
uses: actions/download-artifact@v4
with:
name: "out" # Must match the artifact name from build-web
path: "preview-build"
- name: "Deploy PR Preview to GitHub Pages"
uses: rossjrw/pr-preview-action@v1
with:
source-dir: "preview-build" # Must match path from download-artifact
preview-branch: "gh-pages"
10 changes: 10 additions & 0 deletions packages/nextclade-web/config/next/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ const clientEnv = {
BLOCK_SEARCH_INDEXING: DOMAIN === RELEASE_URL ? '0' : '1',
}

// use PR_NUMBER from GitHub Actions for preview deployments
const { PR_NUMBER } = process.env
const previewNumber = PR_NUMBER
const basePath = previewNumber ? `/nextclade/pr-preview/pr-${previewNumber}` : ''
const assetPrefix = basePath || undefined

const nextConfig: NextConfig = {
// use dynamic basePath on preview
basePath,
assetPrefix,
distDir: `.build/${process.env.NODE_ENV}/tmp`,
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx', 'all-contributorsrc'],
onDemandEntries: {
Expand All @@ -79,6 +88,7 @@ const nextConfig: NextConfig = {
experimental: {
reactRoot: true,
scrollRestoration: true,
esmExternals: 'loose',
},
swcMinify: true,
productionBrowserSourceMaps: ENABLE_SOURCE_MAPS,
Expand Down
Loading