Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci
- name: Build website
run: npm run build

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: build

deploy:
Comment on lines +12 to +33
name: Deploy to GitHub Pages
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
26 changes: 26 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test deployment

on:
pull_request:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci
- name: Test build website
run: npm run build
Comment on lines +12 to +26
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
node_modules

# Production
build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
36 changes: 32 additions & 4 deletions Installer scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ function Invoke-Download([string]$url, [string]$dest) {
}
}

function Get-FileSha256([string]$path) {
if (-not (Test-Path $path)) {
throw "File not found: $path"
}
return (Get-FileHash -Path $path -Algorithm SHA256).Hash.ToLowerInvariant()
}

function Verify-Sha256([string]$path, [string]$expectedHash) {
$actualHash = Get-FileSha256 -path $path
if ($actualHash -ne $expectedHash.ToLowerInvariant()) {
Write-Err "SHA-256 mismatch for $path"
Write-Err " Expected: $expectedHash"
Write-Err " Got: $actualHash"
return $false
}
Write-Ok "SHA-256 verified for $path"
return $true
}

function Invoke-CloneOrPull([string]$repoUrl, [string]$targetDir) {
if (Test-Path (Join-Path $targetDir ".git")) {
Write-Info "'$targetDir' already cloned - pulling latest..."
Expand Down Expand Up @@ -291,8 +310,10 @@ function Install-Portainer {
# Project setup
# ==============================================================================

$BACKEND_REPO = "https://github.com/RGSS-CS/williams-rgss-website-dev-backend.git"
$FRONTEND_COMPOSE_RAW = "https://raw.githubusercontent.com/RGSS-CS/williams-rgss-website-dev-frontend/main/compose.yml"
$BACKEND_REPO = "https://github.com/RGSS-CS/williams-rgss-website-dev-backend.git"
$FRONTEND_COMPOSE_COMMIT = "0bffc67fd4f28f1ee70ceffe88c890663cb3e2c0"
$FRONTEND_COMPOSE_RAW = "https://raw.githubusercontent.com/RGSS-CS/williams-rgss-website-dev-frontend/$FRONTEND_COMPOSE_COMMIT/compose.yml"
$FRONTEND_COMPOSE_SHA256 = "e14e6051fb079c582a487a23ea52e3d2ecac9266cf48b530e469ac86835e40ec"

function Setup-Backend([string]$projectDir, [string]$credFile) {
Write-Host ""
Expand Down Expand Up @@ -366,9 +387,16 @@ function Setup-Frontend([string]$projectDir, [string]$credFile) {
New-Item -ItemType Directory -Force -Path $frontendDir | Out-Null

$composeDest = Join-Path $frontendDir "compose.yml"
$composeTmp = Join-Path $frontendDir "compose.tmp.yml"

Write-Host " -> Downloading frontend/compose.yml..."
Invoke-Download $FRONTEND_COMPOSE_RAW $composeDest
Write-Host " [OK] frontend/compose.yml downloaded."
Invoke-Download $FRONTEND_COMPOSE_RAW $composeTmp
if (-not (Verify-Sha256 -path $composeTmp -expectedHash $FRONTEND_COMPOSE_SHA256)) {
Remove-Item -Path $composeTmp -Force -ErrorAction SilentlyContinue
Exit-WithError "frontend/compose.yml SHA-256 verification failed."
}
Move-Item -Path $composeTmp -Destination $composeDest -Force
Write-Host " [OK] frontend/compose.yml downloaded and verified."

$envPath = Join-Path $frontendDir ".env"
if (Test-Path $envPath) {
Expand Down
Loading
Loading