Setup deploy site #126

Merged
snedadah merged 16 commits from deploy into main 2022-12-30 20:20:56 -05:00
8 changed files with 6983 additions and 14 deletions

View File

@ -50,7 +50,7 @@ steps:
registry: registry.cloud.csclub.uwaterloo.ca
repo: registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging
- name: deploy
- name: deploy (staging)
image: node:16
depends_on:
- publish
@ -60,7 +60,22 @@ steps:
commands:
- echo "The docker build tag is ${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:
event:
exclude:

View File

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

View File

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

View File

@ -1,4 +1,5 @@
import { PageRoutes } from "data/routes";
import Link from "next/link";
import React from "react";
import styles from "./Sections.module.css";
@ -36,12 +37,14 @@ export function Sections({
{Object.values(data).map((datum, index) => {
return (
<li key={`${datum.name}-${index}`}>
<a href={datum.url}>
<span className={styles.linkNumber}>
{String(index).padStart(2, "0")}{" "}
</span>
<span className={styles.linkName}>{datum.name}</span>
</a>
<span className={styles.linkNumber}>
{String(index).padStart(2, "0")}{" "}
</span>
<span className={styles.linkName}>
<Link className={styles.linkName} href={datum.url}>
{datum.name}
</Link>
</span>
</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} */
let basePath = process.env.NEXT_PUBLIC_BASE_PATH ? process.env.NEXT_PUBLIC_BASE_PATH : "";
const nextConfig = {
basePath: basePath,
assetPrefix: basePath + "/",
publicRuntimeConfig : { basePath: basePath },
// test comment
reactStrictMode: true,
trailingSlash: true,
// This image loader supports `next export`, for optimizing next <Image /> tags
images: {
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 };