Skip to content

Commit

Permalink
feat: add website [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed May 28, 2024
0 parents commit a392c4d
Show file tree
Hide file tree
Showing 233 changed files with 20,181 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Astro",
"image": "ghcr.io/acdh-oeaw/devcontainer-frontend:20",
"customizations": {
"vscode": {
"extensions": [
"astro-build.astro-vscode",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"mikestead.dotenv",
"ms-playwright.playwright",
"stylelint.vscode-stylelint",
"unifiedjs.vscode-mdx"
]
}
}
}
63 changes: 63 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## .gitignore ##

# dependencies
node_modules/
.pnpm-store/

# logs
*.log

# non-public environment variables
.env.local
.env.*.local

# caches
.eslintcache
.stylelintcache
*.tsbuildinfo

# vercel
.vercel

# misc
.DS_Store
.idea/

# astro
dist/
.astro/

# test
/coverage/

# playwright
/blob-report/
/playwright/.cache/
/playwright-report/
/test-results/


## .dockerignore ##

# git
.git/
.gitattributes
.gitignore

# github
.github/

# vscode settings
.vscode/

# environment variables
.env
.env.*

# tests
playwright.config.ts
/e2e/
/test/

# misc
.editorconfig
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true

[*.{yaml,yml}]
indent_style = space
46 changes: 46 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -------------------------------------------------------------------------------------------------
# environment variables
# -------------------------------------------------------------------------------------------------
# - public environment variables must be prefixed with `PUBLIC_`.
# - when adding new environment variables, don't forget to also update the
# validation schema in `./config/env.config.ts`.

# -------------------------------------------------------------------------------------------------
# app
# -------------------------------------------------------------------------------------------------
PUBLIC_APP_BASE_URL="http://localhost:3000"
# PUBLIC_APP_BASE_PATH=
# imprint service
PUBLIC_REDMINE_ID="22508"
# web crawlers
PUBLIC_BOTS="disabled"
# validate environment variables
ENV_VALIDATION="enabled"

# -------------------------------------------------------------------------------------------------
# analytics
# -------------------------------------------------------------------------------------------------
# PUBLIC_GOOGLE_SITE_VERIFICATION=
PUBLIC_MATOMO_BASE_URL="https://matomo.acdh.oeaw.ac.at"
# PUBLIC_MATOMO_ID=

# -------------------------------------------------------------------------------------------------
# keystatic cms
# -------------------------------------------------------------------------------------------------
# KEYSTATIC_GITHUB_CLIENT_ID=
# KEYSTATIC_GITHUB_CLIENT_SECRET=
# KEYSTATIC_SECRET=
# PUBLIC_KEYSTATIC_GITHUB_APP_SLUG=
# PUBLIC_KEYSTATIC_GITHUB_REPO_NAME=
# PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER=
# PUBLIC_KEYSTATIC_MODE="github"

# -------------------------------------------------------------------------------------------------
# registration form
# -------------------------------------------------------------------------------------------------
# EMAIL_CONTACT_ADDRESS=
# EMAIL_CONTACT_ADDRESS_BCC=
# EMAIL_SMTP_PORT="587"
# EMAIL_SMTP_SERVER="smtp.oeaw.ac.at"
# EMAIL_SMTP_USERNAME
# EMAIL_SMTP_PASSWORD
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
131 changes: 131 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Build and deploy

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}-build-deploy"
cancel-in-progress: true

on:
workflow_call:
workflow_dispatch:

jobs:
env:
name: Generate environment variables
runs-on: ubuntu-latest
steps:
- name: Derive environment from git ref
id: environment
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
ENVIRONMENT="production"
APP_NAME_SUFFIX=""
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then
ENVIRONMENT="development"
APP_NAME_SUFFIX="-development"
elif [ "${{github.event_name}}" = "pull_request"]; then
ENVIRONMENT="pr/${{ github.event.pull_request.number }}"
APP_NAME_SUFFIX="-pr-${{ github.event.pull_request.number }}"
else
exit 1
fi
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_OUTPUT
echo "APP_NAME_SUFFIX=$APP_NAME_SUFFIX" >> $GITHUB_OUTPUT
outputs:
environment: "${{ steps.environment.outputs.ENVIRONMENT }}"
app_name: "bruckner-online-website${{ steps.environment.outputs.APP_NAME_SUFFIX }}"
registry: "ghcr.io"
image: "${{ github.repository }}"

vars:
name: Generate public url
needs: [env]
runs-on: ubuntu-latest
environment:
name: "${{ needs.env.outputs.environment }}"
steps:
- name: Generate public URL
id: public_url
run: |
if [ -z "${{ vars.PUBLIC_URL }}" ]; then
PUBLIC_URL="https://${{ needs.env.outputs.app_name }}.${{ vars.KUBE_INGRESS_BASE_DOMAIN }}"
else
PUBLIC_URL="${{ vars.PUBLIC_URL }}"
fi
echo "PUBLIC_URL=$PUBLIC_URL" >> $GITHUB_OUTPUT
outputs:
public_url: "${{ steps.public_url.outputs.PUBLIC_URL }}"

build:
name: Build and push docker image
needs: [env, vars]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: "${{ needs.env.outputs.registry }}"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: "${{ needs.env.outputs.registry }}/${{ needs.env.outputs.image }}"
tags: |
type=raw,value={{sha}}
type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=raw,value=latest

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: "${{ steps.meta.outputs.tags }}"
labels: "${{ steps.meta.outputs.labels }}"
build-args: |
"PUBLIC_APP_BASE_URL=${{ needs.vars.outputs.public_url }}"
"PUBLIC_BOTS=${{ vars.PUBLIC_BOTS }}"
"PUBLIC_KEYSTATIC_GITHUB_APP_SLUG=${{ vars.PUBLIC_KEYSTATIC_GITHUB_APP_SLUG }}"
"PUBLIC_KEYSTATIC_GITHUB_REPO_NAME=${{ vars.PUBLIC_KEYSTATIC_GITHUB_REPO_NAME }}"
"PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER=${{ vars.PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER }}"
"PUBLIC_KEYSTATIC_MODE=${{ vars.PUBLIC_KEYSTATIC_MODE }}"
"PUBLIC_MATOMO_BASE_URL=${{ vars.PUBLIC_MATOMO_BASE_URL }}"
"PUBLIC_MATOMO_ID=${{ vars.PUBLIC_MATOMO_ID }}"
"PUBLIC_REDMINE_ID=${{ vars.SERVICE_ID }}"
secrets: |
"KEYSTATIC_GITHUB_CLIENT_ID=${{ secrets.K8S_SECRET_KEYSTATIC_GITHUB_CLIENT_ID }}"
"KEYSTATIC_GITHUB_CLIENT_SECRET=${{ secrets.K8S_SECRET_KEYSTATIC_GITHUB_CLIENT_SECRET }}"
"KEYSTATIC_SECRET=${{ secrets.K8S_SECRET_KEYSTATIC_SECRET }}"
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
name: Deploy docker image
needs: [env, vars, build]
uses: acdh-oeaw/gl-autodevops-minimal-port/.github/workflows/deploy.yml@main
secrets: inherit
with:
environment: "${{ needs.env.outputs.environment }}"
DOCKER_TAG: "${{ needs.env.outputs.registry }}/${{ needs.env.outputs.image }}"
APP_NAME: "${{ needs.env.outputs.app_name }}"
APP_ROOT: "/"
SERVICE_ID: "${{ vars.SERVICE_ID }}"
PUBLIC_URL: "${{ needs.vars.outputs.public_url }}"
default_port: "3000"
102 changes: 102 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Validate

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}-validate"
cancel-in-progress: true

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
validate:
name: Validate
runs-on: ${{ matrix.os }}
timeout-minutes: 60

strategy:
fail-fast: true
matrix:
node-version: [20.x]
os: [ubuntu-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Necessary because `actions/setup-node` does not yet support `corepack`.
# @see https://github.com/actions/setup-node/issues/531
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Format
run: pnpm run format:check

- name: Lint
run: pnpm run lint:check

- name: Typecheck
run: pnpm run types:check

- name: Test
run: pnpm run test

- name: Get playwright version
run: |
PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --json | jq --raw-output '.[0].devDependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache playwright browsers
uses: actions/cache@v4
id: cache-playwright-browsers
with:
path: "~/.cache/ms-playwright"
key: "${{ matrix.os }}-playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}"

- name: Install playwright browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps
- name: Install playwright browsers (operating system dependencies)
if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
run: pnpm exec playwright install-deps

- name: Build app
run: pnpm run build
env:
PUBLIC_APP_BASE_URL: "http://localhost:3000"
PUBLIC_REDMINE_ID: "${{ vars.SERVICE_ID }}"

- name: Run e2e tests
run: pnpm run test:e2e
env:
PUBLIC_APP_BASE_URL: "http://localhost:3000"

- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

build-deploy:
if: ${{ github.event_name == 'push' }}
needs: [validate]
uses: ./.github/workflows/build-deploy.yml
secrets: inherit
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#access-and-permissions
permissions:
contents: read
packages: write
Loading

0 comments on commit a392c4d

Please sign in to comment.