Skip to content

Commit ac142c2

Browse files
committed
chore: initial commit
0 parents  commit ac142c2

32 files changed

+6430
-0
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.{ts,js}]
12+
quote_type = single
13+
14+
[*.{md,mdx}]
15+
max_line_length = off
16+
trim_trailing_whitespace = false
17+
18+
[*.{yml,yaml}]
19+
quote_type = single

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
release:
8+
types: [published]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version-file: '.nvmrc'
26+
27+
- name: Run npm install
28+
run: npm ci
29+
30+
- name: Run build
31+
run: npm run build
32+
33+
- name: Upload build output
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: build-output
37+
path: /build
38+
retention-days: 1

.github/workflows/deploy.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Deploy
2+
on:
3+
workflow_run:
4+
workflows: ['Build']
5+
types:
6+
- completed
7+
8+
jobs:
9+
checks:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
parameters: ${{ steps.parameters.outputs.result }}
13+
steps:
14+
- if: ${{ github.event.workflow_run.conclusion == 'failure' }}
15+
run: echo 'The triggering workflow failed' && exit 1
16+
17+
- name: Determine deploy parameters
18+
id: parameters
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const eventType = context.payload.workflow_run.event;
23+
const isFork = context.payload.workflow_run.repository.fork;
24+
25+
let parameters;
26+
27+
console.log({eventType, isFork});
28+
29+
if (eventType == "push") {
30+
const branch = context.payload.workflow_run.head_branch;
31+
console.log({branch});
32+
const shouldDeploy = !isFork && branch == "main";
33+
parameters = {
34+
event: "branch",
35+
name: "main",
36+
shouldDeploy
37+
};
38+
} else if (eventType == "pull_request") {
39+
let pull_number = context.payload.workflow_run.pull_requests[0]?.number;
40+
if(!pull_number) {
41+
const response = await github.rest.search.issuesAndPullRequests({q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}',per_page: 1,})
42+
const items = response.data.items
43+
if (items.length < 1) {
44+
throw new Error("No pull request found for the commit")
45+
}
46+
const pullRequestNumber = items[0].number
47+
console.info("Pull request number is", pullRequestNumber)
48+
pull_number = pullRequestNumber
49+
}
50+
const {data: pr} = await github.rest.pulls.get({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
pull_number
54+
});
55+
56+
console.log({pull_number});
57+
58+
parameters = {
59+
event: "pr",
60+
name: `pr-${pull_number}`,
61+
pr_number: pull_number,
62+
shouldDeploy: true
63+
};
64+
} else if (eventType == "release") {
65+
parameters = {
66+
event: "release",
67+
name: context.payload.workflow_run.head_branch,
68+
shouldDeploy: !isFork
69+
};
70+
}
71+
72+
console.log(parameters);
73+
return parameters;
74+
75+
deploy:
76+
runs-on: ubuntu-latest
77+
needs: checks
78+
if: ${{ fromJson(needs.checks.outputs.parameters).shouldDeploy }}
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v4
82+
83+
- name: Load parameters
84+
id: parameters
85+
uses: actions/github-script@v7
86+
with:
87+
script: |
88+
const json = `${{ needs.checks.outputs.parameters }}`;
89+
const parameters = JSON.parse(json);
90+
core.setOutput("event", parameters.event);
91+
core.setOutput("name", parameters.name);
92+
core.setOutput("shouldDeploy", parameters.shouldDeploy);
93+
94+
- run: |
95+
echo "Starting docs deployment for ${{ steps.parameters.outputs.event }} ${{ steps.parameters.outputs.name }}"
96+
97+
- name: Download artifact
98+
uses: actions/github-script@v7
99+
with:
100+
script: |
101+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
run_id: context.payload.workflow_run.id,
105+
});
106+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
107+
return artifact.name == "build-output"
108+
})[0];
109+
let download = await github.rest.actions.downloadArtifact({
110+
owner: context.repo.owner,
111+
repo: context.repo.repo,
112+
artifact_id: matchArtifact.id,
113+
archive_format: 'zip',
114+
});
115+
let fs = require('fs');
116+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/build-output.zip`, Buffer.from(download.data));
117+
118+
- name: Unzip artifact
119+
run: unzip "${{ github.workspace }}/build-output.zip" -d "${{ github.workspace }}/build"
120+
121+
# - name: Deploy Subdomain
122+
# env:
123+
# TF_VAR_prefix_name: ${{ steps.parameters.outputs.name}}
124+
# TF_VAR_prefix_event_type: ${{ steps.parameters.outputs.event }}
125+
# CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
126+
# CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
127+
# TF_STATE_POSTGRES_CONN_STR: ${{ secrets.TF_STATE_POSTGRES_CONN_STR }}
128+
# uses: gruntwork-io/terragrunt-action@v2
129+
# with:
130+
# tg_version: '0.58.12'
131+
# tofu_version: '1.7.1'
132+
# tg_dir: 'deployment/modules/cloudflare/docs'
133+
# tg_command: 'apply'
134+
135+
# - name: Deploy Docs Subdomain Output
136+
# id: docs-output
137+
# env:
138+
# TF_VAR_prefix_name: ${{ steps.parameters.outputs.name}}
139+
# TF_VAR_prefix_event_type: ${{ steps.parameters.outputs.event }}
140+
# CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
141+
# CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
142+
# TF_STATE_POSTGRES_CONN_STR: ${{ secrets.TF_STATE_POSTGRES_CONN_STR }}
143+
# uses: gruntwork-io/terragrunt-action@v2
144+
# with:
145+
# tg_version: '0.58.12'
146+
# tofu_version: '1.7.1'
147+
# tg_dir: 'deployment/modules/cloudflare/docs'
148+
# tg_command: 'output -json'
149+
150+
# - name: Output Cleaning
151+
# id: clean
152+
# run: |
153+
# TG_OUT=$(echo '${{ steps.docs-output.outputs.tg_action_output }}' | sed 's|%0A|\n|g ; s|%3C|<|g' | jq -c .)
154+
# echo "output=$TG_OUT" >> $GITHUB_OUTPUT
155+
156+
# - name: Publish to Cloudflare Pages
157+
# uses: cloudflare/pages-action@v1
158+
# with:
159+
# apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN_PAGES_UPLOAD }}
160+
# accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
161+
# projectName: ${{ fromJson(steps.clean.outputs.output).pages_project_name.value }}
162+
# workingDirectory: 'docs'
163+
# directory: 'build'
164+
# branch: ${{ steps.parameters.outputs.name }}
165+
# wranglerVersion: '3'
166+
167+
# - name: Deploy Docs Release Domain
168+
# if: ${{ steps.parameters.outputs.event == 'release' }}
169+
# env:
170+
# TF_VAR_prefix_name: ${{ steps.parameters.outputs.name}}
171+
# CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
172+
# CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
173+
# TF_STATE_POSTGRES_CONN_STR: ${{ secrets.TF_STATE_POSTGRES_CONN_STR }}
174+
# uses: gruntwork-io/terragrunt-action@v2
175+
# with:
176+
# tg_version: '0.58.12'
177+
# tofu_version: '1.7.1'
178+
# tg_dir: 'deployment/modules/cloudflare/docs-release'
179+
# tg_command: 'apply'
180+
181+
# - name: Comment
182+
# uses: actions-cool/maintain-one-comment@v3
183+
# if: ${{ steps.parameters.outputs.event == 'pr' }}
184+
# with:
185+
# number: ${{ fromJson(needs.checks.outputs.parameters).pr_number }}
186+
# body: |
187+
# 📖 Documentation deployed to [${{ fromJson(steps.clean.outputs.output).immich_app_branch_subdomain.value }}](https://${{ fromJson(steps.clean.outputs.output).immich_app_branch_subdomain.value }})
188+
# emojis: 'rocket'
189+
# body-include: '<!-- Docs PR URL -->'

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
web-unit-tests:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
25+
- name: Run npm install
26+
run: npm ci
27+
28+
- name: Run linter
29+
run: npm run lint
30+
if: ${{ !cancelled() }}
31+
32+
- name: Run formatter
33+
run: npm run format
34+
if: ${{ !cancelled() }}
35+
36+
- name: Run tsc
37+
run: npm run check
38+
if: ${{ !cancelled() }}
39+
40+
- name: Run unit tests
41+
run: npm test
42+
if: ${{ !cancelled() }}

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
node_modules
2+
3+
# Output
4+
.output
5+
.vercel
6+
/.svelte-kit
7+
/build
8+
9+
# OS
10+
.DS_Store
11+
Thumbs.db
12+
13+
# Env
14+
.env
15+
.env.*
16+
!.env.example
17+
!.env.test
18+
19+
# Vite
20+
vite.config.js.timestamp-*
21+
vite.config.ts.timestamp-*

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.15

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Package Managers
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"plugins": ["prettier-plugin-svelte"],
6+
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
7+
}

0 commit comments

Comments
 (0)