Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website deployment #1295

Merged
merged 4 commits into from Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-next.yml
Expand Up @@ -44,7 +44,7 @@ jobs:
run: cd lib && npm run test

- name: Build website
run: cd website && yarn build
run: cd website && SITE_VERSION=next yarn build

- name: Publish NEXT version to npm
run: |
Expand Down
16 changes: 16 additions & 0 deletions scripts/release-website.js
Expand Up @@ -52,6 +52,21 @@ const getVersionsInS3Bucket = async () => {
return versionsFromPrevDirectory.concat(versions);
};

const buildSite = (version) => {
return new Promise((resolve, reject) => {
console.log(`Building site with version ${version}/`);
exec(`SITE_VERSION=${version} yarn build`, (error, stdout, stderr) => {
if (error) {
throw new Error(error.message);
}
if (stderr) {
throw new Error(stderr);
}
resolve(stdout);
});
});
};

const removeBucket = (version) => {
return new Promise((resolve, reject) => {
console.log(`Removing s3://${BUCKET_NAME}/${DIRECTORY}${version}/`);
Expand Down Expand Up @@ -113,6 +128,7 @@ const deploy = async () => {
);
const existingVersionsInBucket = await getVersionsInS3Bucket();
const isNewLatest = !existingVersionsInBucket.includes(majorVersionToDeploy);
await buildSite(majorVersionToDeploy);
await removeBucket(majorVersionToDeploy);
await moveToBucket(majorVersionToDeploy);
const listAvailableVersions = await getVersionsInS3Bucket();
Expand Down
4 changes: 4 additions & 0 deletions website/next.config.js
@@ -1,3 +1,5 @@
const isProd = process.env.NODE_ENV === "production";

/** @type {import('next').NextConfig} */
module.exports = {
images: {
Expand Down Expand Up @@ -31,4 +33,6 @@ module.exports = {
"/": { page: "/overview/introduction" },
};
},
assetPrefix: isProd ? `/halstack/${process.env.SITE_VERSION}` : undefined,
marcialfps marked this conversation as resolved.
Show resolved Hide resolved
basePath: isProd ? `/halstack/${process.env.SITE_VERSION}` : undefined,
};
2 changes: 1 addition & 1 deletion website/screens/common/Image.tsx
@@ -1,7 +1,7 @@
import NextImage from "next/image";

const customLoader = ({ src }: { src: string }) => {
return src;
return process.env.NODE_ENV === "production" ? src.replace("//", "/") : src;
};

type ImageProps = {
Expand Down
4 changes: 2 additions & 2 deletions website/screens/common/sidenav/SidenavLogo.tsx
@@ -1,6 +1,6 @@
import styled from "styled-components";
import Image from "../Image";
import halstackLogo from "../images/halstack_logo.svg";
import Image from "@/common/Image";
import halstackLogo from "@/common/images/halstack_logo.svg";

const SidenavLogo = () => {
return (
Expand Down