Skip to content

Commit

Permalink
Merge pull request #1295 from dxc-technology/marcialfps-website-deploy
Browse files Browse the repository at this point in the history
Website deployment
  • Loading branch information
marcialfps committed Sep 22, 2022
2 parents 86199b7 + 67969ca commit ed98597
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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,
basePath: isProd ? `/halstack/${process.env.SITE_VERSION}` : undefined,
};
2 changes: 1 addition & 1 deletion website/screens/common/Image.tsx
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ed98597

Please sign in to comment.