Setup deploy site (#126)
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Shahan Nedadahandeh 2022-12-30 20:20:55 -05:00
parent 9a60c6b779
commit 2dca08ccef
8 changed files with 6983 additions and 14 deletions

View File

@ -50,7 +50,7 @@ steps:
registry: registry.cloud.csclub.uwaterloo.ca registry: registry.cloud.csclub.uwaterloo.ca
repo: registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging repo: registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging
- name: deploy - name: deploy (staging)
image: node:16 image: node:16
depends_on: depends_on:
- publish - publish
@ -60,7 +60,22 @@ steps:
commands: commands:
- echo "The docker build tag is ${DRONE_BRANCH//\//-}" - echo "The docker build tag is ${DRONE_BRANCH//\//-}"
- 'curl -H "Authorization: $STAGING_AUTH_TOKEN" https://csclub.uwaterloo.ca/~snedadah/webhooks/cscclassprofilestaging?ref=${DRONE_BRANCH//\//-}' - 'curl -H "Authorization: $STAGING_AUTH_TOKEN" https://csclub.uwaterloo.ca/~snedadah/webhooks/cscclassprofilestaging?ref=${DRONE_BRANCH//\//-}'
- name: deploy (production)
image: node:16
depends_on:
- export
environment:
SSH_KEY:
from_secret: DEPLOYMENT_SSH_KEY
commands:
- 'echo "$SSH_KEY" > /tmp/ssh_key'
- chmod 600 /tmp/ssh_key
- ssh -4 -i /tmp/ssh_key www@caffeine.csclub.uwaterloo.ca -o StrictHostKeyChecking=no '~/bin/classprofile/deploy-classprofile-2022.sh'
when:
branch:
- main
trigger: trigger:
event: event:
exclude: exclude:

View File

@ -1,6 +1,7 @@
import { pageRoutes } from "data/routes"; import { pageRoutes } from "data/routes";
import Link from "next/link"; import Link from "next/link";
import React, { useState } from "react"; import React, { useState } from "react";
import { basePath } from "utils/getBasePath";
import { Sections } from "./Sections"; import { Sections } from "./Sections";
@ -32,7 +33,7 @@ export function Header() {
className={styles.menuIcon} className={styles.menuIcon}
> >
<img <img
src="/images/menuIcon.svg" src={basePath + "/images/menuIcon.svg"}
width="50" width="50"
height="50" height="50"
draggable="false" draggable="false"
@ -52,7 +53,7 @@ export function Header() {
}} }}
> >
<img <img
src="/images/rightArrow.svg" src={basePath + "/images/rightArrow.svg"}
className={styles.arrowIcon} className={styles.arrowIcon}
width="50" width="50"
height="50" height="50"

View File

@ -50,11 +50,11 @@
color: var(--primary-text); color: var(--primary-text);
} }
.nav li a:hover .linkName { .linkName:hover {
text-decoration: underline; text-decoration: underline;
} }
.nav li .linkName { .linkName {
margin: 0; margin: 0;
display: inline; display: inline;
} }

View File

@ -1,4 +1,5 @@
import { PageRoutes } from "data/routes"; import { PageRoutes } from "data/routes";
import Link from "next/link";
import React from "react"; import React from "react";
import styles from "./Sections.module.css"; import styles from "./Sections.module.css";
@ -36,12 +37,14 @@ export function Sections({
{Object.values(data).map((datum, index) => { {Object.values(data).map((datum, index) => {
return ( return (
<li key={`${datum.name}-${index}`}> <li key={`${datum.name}-${index}`}>
<a href={datum.url}> <span className={styles.linkNumber}>
<span className={styles.linkNumber}> {String(index).padStart(2, "0")}{" "}
{String(index).padStart(2, "0")}{" "} </span>
</span> <span className={styles.linkName}>
<span className={styles.linkName}>{datum.name}</span> <Link className={styles.linkName} href={datum.url}>
</a> {datum.name}
</Link>
</span>
</li> </li>
); );
})} })}

27
deploy.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -ex
ulimit -u 512
DIR=$(mktemp --directory)
trap "rm -rf $DIR" EXIT
pushd $DIR
git clone file:///srv/git/www/cs-2022-class-profile.git --depth=1
cd cs-2022-class-profile
export NEXT_PUBLIC_BASE_PATH="/classprofile/2022"
npm install
npm run build
npm run export
chgrp -R www out
chmod -R g+w out
shopt -s dotglob
rm -rf /srv/classprofile/2022/*
mv out/* /srv/classprofile/2022/
popd

View File

@ -1,11 +1,18 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
let basePath = process.env.NEXT_PUBLIC_BASE_PATH ? process.env.NEXT_PUBLIC_BASE_PATH : "";
const nextConfig = { const nextConfig = {
basePath: basePath,
assetPrefix: basePath + "/",
publicRuntimeConfig : { basePath: basePath },
// test comment
reactStrictMode: true, reactStrictMode: true,
trailingSlash: true, trailingSlash: true,
// This image loader supports `next export`, for optimizing next <Image /> tags // This image loader supports `next export`, for optimizing next <Image /> tags
images: { images: {
loader: 'akamai', loader: 'akamai',
path: '', path: basePath,
}, },
} }

6912
package-lock.json generated

File diff suppressed because it is too large Load Diff

6
utils/getBasePath.ts Normal file
View File

@ -0,0 +1,6 @@
import config from "next/config";
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { publicRuntimeConfig } = config();
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const basePath = publicRuntimeConfig.basePath as string;
export { basePath };