Skip to content

Commit 0852940

Browse files
committed
feat: add amc website
0 parents  commit 0852940

File tree

181 files changed

+18809
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+18809
-0
lines changed

.devcontainer/devcontainer.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Astro",
3+
"image": "ghcr.io/acdh-oeaw/devcontainer-frontend:20",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": [
7+
"astro-build.astro-vscode",
8+
"bradlc.vscode-tailwindcss",
9+
"dbaeumer.vscode-eslint",
10+
"editorconfig.editorconfig",
11+
"esbenp.prettier-vscode",
12+
"mikestead.dotenv",
13+
"ms-playwright.playwright",
14+
"stylelint.vscode-stylelint",
15+
"unifiedjs.vscode-mdx"
16+
]
17+
}
18+
}
19+
}

.dockerignore

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## .gitignore ##
2+
3+
# dependencies
4+
node_modules/
5+
.pnpm-store/
6+
7+
# logs
8+
*.log
9+
10+
# non-public environment variables
11+
.env.local
12+
.env.*.local
13+
14+
# caches
15+
.eslintcache
16+
.stylelintcache
17+
*.tsbuildinfo
18+
19+
# vercel
20+
.vercel
21+
22+
# misc
23+
.DS_Store
24+
.idea/
25+
26+
# astro
27+
dist/
28+
.astro/
29+
30+
# test
31+
/coverage/
32+
33+
# playwright
34+
/blob-report/
35+
/playwright/.cache/
36+
/playwright-report/
37+
/test-results/
38+
39+
40+
## .dockerignore ##
41+
42+
# git
43+
.git/
44+
.gitattributes
45+
.gitignore
46+
47+
# github
48+
.github/
49+
50+
# vscode settings
51+
.vscode/
52+
53+
# environment variables
54+
.env
55+
.env.*
56+
57+
# tests
58+
playwright.config.ts
59+
/e2e/
60+
/test/
61+
62+
# misc
63+
.editorconfig

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = tab
8+
insert_final_newline = true
9+
max_line_length = 100
10+
trim_trailing_whitespace = true
11+
12+
[*.{yaml,yml}]
13+
indent_style = space

.env.local.example

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# environment variables
3+
# -------------------------------------------------------------------------------------------------
4+
# - public environment variables must be prefixed with `PUBLIC_`.
5+
# - when adding new environment variables, don't forget to also update the
6+
# validation schema in `./config/env.config.ts`.
7+
8+
# -------------------------------------------------------------------------------------------------
9+
# app
10+
# -------------------------------------------------------------------------------------------------
11+
PUBLIC_APP_BASE_URL="http://localhost:3000"
12+
# PUBLIC_APP_BASE_PATH=
13+
# imprint service
14+
PUBLIC_REDMINE_ID="11419"
15+
# web crawlers
16+
PUBLIC_BOTS="disabled"
17+
# validate environment variables
18+
ENV_VALIDATION="enabled"
19+
20+
# -------------------------------------------------------------------------------------------------
21+
# analytics
22+
# -------------------------------------------------------------------------------------------------
23+
PUBLIC_MATOMO_BASE_URL="https://matomo.acdh.oeaw.ac.at"
24+
# PUBLIC_MATOMO_ID=
25+
26+
# -------------------------------------------------------------------------------------------------
27+
# keystatic cms
28+
# -------------------------------------------------------------------------------------------------
29+
# KEYSTATIC_GITHUB_CLIENT_ID=
30+
# KEYSTATIC_GITHUB_CLIENT_SECRET=
31+
# KEYSTATIC_SECRET=
32+
# PUBLIC_KEYSTATIC_GITHUB_APP_SLUG=
33+
# PUBLIC_KEYSTATIC_GITHUB_REPO_NAME=
34+
# PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER=
35+
# PUBLIC_KEYSTATIC_MODE="github"
36+
37+
# -------------------------------------------------------------------------------------------------
38+
# registration form
39+
# -------------------------------------------------------------------------------------------------
40+
# EMAIL_CONTACT_ADDRESS=
41+
# EMAIL_SMTP_PORT="587"
42+
# EMAIL_SMTP_SERVER="smtp.oeaw.ac.at"

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/build-deploy.yml

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Build and deploy
2+
3+
concurrency:
4+
group: "${{ github.workflow }}-${{ github.ref }}-build-deploy"
5+
cancel-in-progress: true
6+
7+
on:
8+
workflow_call:
9+
workflow_dispatch:
10+
11+
jobs:
12+
env:
13+
name: Generate environment variables
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Derive environment from git ref
17+
id: environment
18+
run: |
19+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
20+
ENVIRONMENT="production"
21+
APP_NAME_SUFFIX=""
22+
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then
23+
ENVIRONMENT="development"
24+
APP_NAME_SUFFIX="-development"
25+
elif [ "${{github.event_name}}" = "pull_request"]; then
26+
ENVIRONMENT="pr/${{ github.event.pull_request.number }}"
27+
APP_NAME_SUFFIX="-pr-${{ github.event.pull_request.number }}"
28+
else
29+
exit 1
30+
fi
31+
32+
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_OUTPUT
33+
echo "APP_NAME_SUFFIX=$APP_NAME_SUFFIX" >> $GITHUB_OUTPUT
34+
outputs:
35+
environment: "${{ steps.environment.outputs.ENVIRONMENT }}"
36+
app_name: "amc-website${{ steps.environment.outputs.APP_NAME_SUFFIX }}"
37+
registry: "ghcr.io"
38+
image: "${{ github.repository }}"
39+
40+
vars:
41+
name: Generate public url
42+
needs: [env]
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: "${{ needs.env.outputs.environment }}"
46+
steps:
47+
- name: Generate public URL
48+
id: public_url
49+
run: |
50+
if [ -z "${{ vars.PUBLIC_URL }}" ]; then
51+
PUBLIC_URL="https://${{ needs.env.outputs.app_name }}.${{ vars.KUBE_INGRESS_BASE_DOMAIN }}"
52+
else
53+
PUBLIC_URL="${{ vars.PUBLIC_URL }}"
54+
fi
55+
56+
echo "PUBLIC_URL=$PUBLIC_URL" >> $GITHUB_OUTPUT
57+
outputs:
58+
public_url: "${{ steps.public_url.outputs.PUBLIC_URL }}"
59+
60+
build:
61+
name: Build and push docker image
62+
needs: [env, vars]
63+
runs-on: ubuntu-latest
64+
permissions:
65+
contents: read
66+
packages: write
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
75+
- name: Log in to the Container registry
76+
uses: docker/login-action@v3
77+
with:
78+
registry: "${{ needs.env.outputs.registry }}"
79+
username: "${{ github.actor }}"
80+
password: "${{ secrets.GITHUB_TOKEN }}"
81+
82+
- name: Extract metadata (tags, labels) for Docker
83+
id: meta
84+
uses: docker/metadata-action@v5
85+
with:
86+
images: "${{ needs.env.outputs.registry }}/${{ needs.env.outputs.image }}"
87+
tags: |
88+
type=raw,value={{sha}}
89+
type=ref,event=branch
90+
# type=ref,event=pr
91+
# type=semver,pattern={{version}}
92+
# type=semver,pattern={{major}}.{{minor}}
93+
# type=raw,value=latest
94+
95+
- name: Build and push Docker image
96+
uses: docker/build-push-action@v5
97+
with:
98+
context: .
99+
push: true
100+
tags: "${{ steps.meta.outputs.tags }}"
101+
labels: "${{ steps.meta.outputs.labels }}"
102+
build-args: |
103+
"PUBLIC_APP_BASE_URL=${{ needs.vars.outputs.public_url }}"
104+
"PUBLIC_BOTS=${{ vars.PUBLIC_BOTS }}"
105+
"PUBLIC_KEYSTATIC_GITHUB_APP_SLUG=${{ vars.PUBLIC_KEYSTATIC_GITHUB_APP_SLUG }}"
106+
"PUBLIC_KEYSTATIC_GITHUB_REPO_NAME=${{ vars.PUBLIC_KEYSTATIC_GITHUB_REPO_NAME }}"
107+
"PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER=${{ vars.PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER }}"
108+
"PUBLIC_KEYSTATIC_MODE=${{ vars.PUBLIC_KEYSTATIC_MODE }}"
109+
"PUBLIC_MATOMO_BASE_URL=${{ vars.PUBLIC_MATOMO_BASE_URL }}"
110+
"PUBLIC_MATOMO_ID=${{ vars.PUBLIC_MATOMO_ID }}"
111+
"PUBLIC_REDMINE_ID=${{ vars.SERVICE_ID }}"
112+
secrets: |
113+
"KEYSTATIC_GITHUB_CLIENT_ID=${{ secrets.K8S_SECRET_KEYSTATIC_GITHUB_CLIENT_ID }}"
114+
"KEYSTATIC_GITHUB_CLIENT_SECRET=${{ secrets.K8S_SECRET_KEYSTATIC_GITHUB_CLIENT_SECRET }}"
115+
"KEYSTATIC_SECRET=${{ secrets.K8S_SECRET_KEYSTATIC_SECRET }}"
116+
cache-from: type=gha
117+
cache-to: type=gha,mode=max
118+
119+
deploy:
120+
name: Deploy docker image
121+
needs: [env, vars, build]
122+
uses: acdh-oeaw/gl-autodevops-minimal-port/.github/workflows/deploy.yml@main
123+
secrets: inherit
124+
with:
125+
environment: "${{ needs.env.outputs.environment }}"
126+
DOCKER_TAG: "${{ needs.env.outputs.registry }}/${{ needs.env.outputs.image }}"
127+
APP_NAME: "${{ needs.env.outputs.app_name }}"
128+
APP_ROOT: "/"
129+
SERVICE_ID: "${{ vars.SERVICE_ID }}"
130+
PUBLIC_URL: "${{ needs.vars.outputs.public_url }}"
131+
default_port: "3000"

.github/workflows/validate.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Validate
2+
3+
concurrency:
4+
group: "${{ github.workflow }}-${{ github.ref }}-validate"
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
push:
12+
branches:
13+
- main
14+
15+
jobs:
16+
validate:
17+
name: Validate
18+
runs-on: ${{ matrix.os }}
19+
timeout-minutes: 60
20+
21+
strategy:
22+
fail-fast: true
23+
matrix:
24+
node-version: [20.x]
25+
os: [ubuntu-latest]
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
# Necessary because `actions/setup-node` does not yet support `corepack`.
32+
# @see https://github.com/actions/setup-node/issues/531
33+
- name: Install pnpm
34+
uses: pnpm/action-setup@v4
35+
36+
- name: Use Node.js ${{ matrix.node-version }}
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: ${{ matrix.node-version }}
40+
cache: "pnpm"
41+
42+
- name: Install dependencies
43+
run: pnpm install --frozen-lockfile
44+
45+
- name: Format
46+
run: pnpm run format:check
47+
48+
- name: Lint
49+
run: pnpm run lint:check
50+
51+
- name: Typecheck
52+
run: pnpm run types:check
53+
54+
- name: Test
55+
run: pnpm run test
56+
57+
- name: Get playwright version
58+
run: |
59+
PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --json | jq --raw-output '.[0].devDependencies["@playwright/test"].version')
60+
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
61+
62+
- name: Cache playwright browsers
63+
uses: actions/cache@v4
64+
id: cache-playwright-browsers
65+
with:
66+
path: "~/.cache/ms-playwright"
67+
key: "${{ matrix.os }}-playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}"
68+
69+
- name: Install playwright browsers
70+
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
71+
run: pnpm exec playwright install --with-deps
72+
- name: Install playwright browsers (operating system dependencies)
73+
if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
74+
run: pnpm exec playwright install-deps
75+
76+
- name: Build app
77+
run: pnpm run build
78+
env:
79+
PUBLIC_APP_BASE_URL: "http://localhost:3000"
80+
PUBLIC_REDMINE_ID: "${{ vars.SERVICE_ID }}"
81+
82+
- name: Run e2e tests
83+
run: pnpm run test:e2e
84+
env:
85+
PUBLIC_APP_BASE_URL: "http://localhost:3000"
86+
87+
- uses: actions/upload-artifact@v4
88+
if: always()
89+
with:
90+
name: playwright-report
91+
path: playwright-report/
92+
retention-days: 30
93+
94+
build-deploy:
95+
if: ${{ github.event_name == 'push' }}
96+
needs: [validate]
97+
uses: ./.github/workflows/build-deploy.yml
98+
secrets: inherit
99+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#access-and-permissions
100+
permissions:
101+
contents: read
102+
packages: write

0 commit comments

Comments
 (0)