Skip to content
Open
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
29 changes: 23 additions & 6 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,33 @@ jobs:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Generate sitemap
run: yarn generate-sitemap
env:
# URLs are resolved from ISAAC_ENV in scripts/sitemap-config.ts,
# mirroring the envSpecific() pattern from src/app/services/constants.ts
ISAAC_ENV: ${{ startsWith(github.ref, 'refs/tags/') && 'production' || 'staging' }}

- name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta cs
id: meta-cs
uses: docker/metadata-action@v5
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ghcr.io/${{ github.repository }}-cs
tags: |
Expand All @@ -36,7 +53,7 @@ jobs:
type=ref,event=tag
- name: Docker meta cs-renderer
id: meta-cs-renderer
uses: docker/metadata-action@v5
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ghcr.io/${{ github.repository }}-cs-renderer
tags: |
Expand All @@ -45,7 +62,7 @@ jobs:
# tag event
type=ref,event=tag
- name: Build and push cs Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
file: Dockerfile-react
context: .
Expand All @@ -55,7 +72,7 @@ jobs:
tags: ${{ steps.meta-cs.outputs.tags }}
labels: ${{ steps.meta-cs.outputs.labels }}
- name: Build and push cs-renderer Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
file: Dockerfile-react
context: .
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/update-sitemap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Update Sitemap

on:
schedule:
- cron: "0 6 * * *" # Daily at 06:00 UTC
workflow_dispatch: # Allow manual trigger

jobs:
update-sitemap:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout react app
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout content repo
uses: actions/checkout@v4
with:
repository: isaaccomputerscience/isaac-content
path: content-repo
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Index content dates
run: yarn index-content-dates
env:
CONTENT_REPO_PATH: ${{ github.workspace }}/content-repo

- name: Generate sitemap
run: yarn generate-sitemap
env:
ISAAC_ENV: production

- name: Commit if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add public/sitemap.xml scripts/content-dates.json
git diff --cached --quiet || \
(git commit -m "chore: update sitemap [skip ci]" && git push)
8 changes: 7 additions & 1 deletion config/webpack.config.cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const { merge } = require('webpack-merge');
const webpack = require('webpack');

module.exports = env => {
const webpackConfigCs = env => {

let configCS = {
entry: {
Expand Down Expand Up @@ -39,10 +39,16 @@ module.exports = env => {
},{
from: resolve('public/robots.txt'),
to: 'robots.txt',
}, {
from: resolve('public/sitemap.xml'),
to: 'sitemap.xml',
noErrorOnMissing: true, // Sitemap is generated separately so is ok
}]
}),
],
};

return merge(configCommon(env), configCS);
};

module.exports = webpackConfigCs;
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"uuid": "^9.0.1"
},
"scripts": {
"generate-sitemap": "ts-node --project scripts/tsconfig.json scripts/generate-sitemap.ts",
"index-content-dates": "ts-node --project scripts/tsconfig.json scripts/index-content-dates.ts",
"build-cs": "webpack --env prod --config config/webpack.config.cs.js",
"build-dev": "webpack --config config/webpack.config.cs.js",
"start": "webpack-dev-server --hot --port 8003 --history-api-fallback --config config/webpack.config.cs.js --allowed-hosts=true",
Expand Down Expand Up @@ -104,7 +106,9 @@
}
}
},
"eslintIgnore": ["/src/IsaacApiTypesAutoGenerated.tsx"],
"eslintIgnore": [
"/src/IsaacApiTypesAutoGenerated.tsx"
],
"browserslist": [
">0.2%",
"not dead",
Expand All @@ -128,9 +132,11 @@
"@types/html-to-text": "^9.0.4",
"@types/jest": "^29.5.12",
"@types/js-cookie": "^3.0.6",
"@types/js-yaml": "^4.0.9",
"@types/katex": "^0.16.7",
"@types/leaflet": "^1.9.6",
"@types/lodash": "^4.17.5",
"@types/node": "^20.11.0",
"@types/object-hash": "^3.0.4",
"@types/qrcode": "^1.5.2",
"@types/react-beautiful-dnd": "^13.1.8",
Expand Down Expand Up @@ -166,6 +172,7 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-watch-typeahead": "^2.2.2",
"js-yaml": "^4.1.1",
"mini-css-extract-plugin": "^2.9.0",
"msw": "^1.3.3",
"prettier": "^3.0.3",
Expand All @@ -179,6 +186,7 @@
"style-loader": "^3.3.4",
"ts-jest": "^29.4.6",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^4.9.5",
"webpack": "^5.101.3",
"webpack-bundle-analyzer": "^4.10.2",
Expand Down
5 changes: 4 additions & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ Disallow:
# Allow Googlebot access to everything
User-agent: Googlebot
User-agent: Bingbot
Disallow:
Disallow:

# Sitemap location
Sitemap: https://isaaccomputerscience.org/sitemap.xml
Loading
Loading