Skip to content

Commit 8544038

Browse files
authored
Actions dashboard (#1)
* initial DRF implementation * backend now successfully receiving and storing github webhooks * implement public facing api * add ordering to workflow run model * added settings to prepare for prod release * add docker configs for backend * remove unused route leftover from template * minor wording updates and cleanup * swap to link for GitHub icon container * accessibility: add some missing aria labels and hide irrelevant icons * add throttling and some code cleanup * remove admin site url access * add ruff linting to Python files and install pre-commit * disable COM812 trailing comma in favor of formatter * modify docker compose and nginx for new api * move frontend into its own folder * update api to use subdomain at api.sourcedepth.com * update workflows trigger directories * add api.sourcedepth.com to allowed hosts * several bug fixes * adds filtering on foreign keys to public api * add output to api * add actions dashboard to frontend
1 parent 02aaee8 commit 8544038

File tree

133 files changed

+3152
-109
lines changed

Some content is hidden

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

133 files changed

+3152
-109
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ mdx
44
.github
55
.output
66
.tanstack
7-
.vscode
7+
.vscode
8+
db.sqlite3
9+
.env
10+
.venv
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build Image 🏗️ and Deploy Backend 🛠️ to VPS 🚀
2+
3+
# Builds the Docker image and deploys it to the VPS.
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- "backend/**"
12+
release:
13+
types: [published]
14+
15+
jobs:
16+
build-versioned:
17+
runs-on: ubuntu-latest
18+
name: Built Versioned Image
19+
if: github.event_name == 'release'
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
- name: Extract metadata (tags, labels) for Docker
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: ${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth-api
28+
- name: Login to Docker Hub
29+
uses: docker/login-action@v3
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: ./backend
37+
push: true
38+
tags: |
39+
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth-api:${{ github.event.release.tag_name }}
40+
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth-api:latest
41+
annotations: ${{ steps.meta.outputs.annotations }}
42+
build-latest:
43+
runs-on: ubuntu-latest
44+
name: Build Latest Image
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: ${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth-api
53+
- name: Login to Docker Hub
54+
uses: docker/login-action@v3
55+
with:
56+
username: ${{ secrets.DOCKERHUB_USERNAME }}
57+
password: ${{ secrets.DOCKERHUB_TOKEN }}
58+
- name: Build and push Docker image
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: ./backend
62+
push: ${{ github.event_name != 'pull_request' }}
63+
tags: |
64+
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth-api:latest
65+
annotations: ${{ steps.meta.outputs.annotations }}
66+
update-files:
67+
name: Update Files on VPS
68+
needs: build-latest
69+
uses: ./.github/workflows/update-files.yaml
70+
secrets: inherit
71+
deploy:
72+
runs-on: ubuntu-latest
73+
name: Deploy to VPS
74+
needs: update-files
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
78+
- name: Build and restart Docker containers
79+
uses: appleboy/ssh-action@v1
80+
with:
81+
host: ${{ secrets.SSH_HOST }}
82+
username: ${{ secrets.SSH_USERNAME }}
83+
key: ${{ secrets.SSH_KEY }}
84+
port: ${{ secrets.SSH_PORT }}
85+
passphrase: ${{ secrets.SSH_PASSPHRASE }}
86+
script: |
87+
cd ~/sourcedepth.com
88+
docker compose down
89+
docker compose up --pull always -d
90+
docker system prune -f

.github/workflows/build-and-deploy.yaml renamed to .github/workflows/build-and-deploy-frontend.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Image 🏗️ and Deploy to VPS 🚀
1+
name: Build Image 🏗️ and Deploy Frontend 💻 to VPS 🚀
22

33
# Builds the Docker image and deploys it to the VPS.
44

@@ -7,15 +7,20 @@ on:
77
push:
88
branches:
99
- main
10-
# Don't run full build on only public or mdx changes
11-
paths-ignore:
12-
- "!public/**"
13-
- "!mdx/**"
14-
- "!LICENSE"
15-
- "!README.md"
16-
- "!.gitignore"
17-
- "!.dockerignore"
18-
- "!.prettierignore"
10+
paths:
11+
- "frontend/**"
12+
- "!frontend/mdx/**"
13+
- "!frontend/static/**"
14+
# Don't run full build on only public or mdx changes
15+
# paths-ignore:
16+
# - "!public/**"
17+
# - "!mdx/**"
18+
# - "!LICENSE"
19+
# - "!README.md"
20+
# - "!.gitignore"
21+
# - "!.dockerignore"
22+
# - "!.prettierignore"
23+
1924
release:
2025
types: [published]
2126

@@ -40,7 +45,7 @@ jobs:
4045
- name: Build and push Docker image
4146
uses: docker/build-push-action@v6
4247
with:
43-
context: .
48+
context: ./frontend
4449
push: true
4550
tags: |
4651
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com:${{ github.event.release.tag_name }}
@@ -65,7 +70,7 @@ jobs:
6570
- name: Build and push Docker image
6671
uses: docker/build-push-action@v6
6772
with:
68-
context: .
73+
context: ./frontend
6974
push: ${{ github.event_name != 'pull_request' }}
7075
tags: |
7176
${{ secrets.DOCKERHUB_USERNAME }}/sourcedepth.com:latest

.github/workflows/update-files.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ on:
1111
# Only run this workflow for changes in public or mdx directories
1212
paths:
1313
- "public/**"
14-
- "mdx/**"
14+
- "frontend/mdx/**"
1515
- "nginx/nginx.conf"
16-
- "static/**"
16+
- "frontend/static/**"
1717
release:
1818
types: [published]
1919

@@ -32,6 +32,6 @@ jobs:
3232
key: ${{ secrets.SSH_KEY }}
3333
port: ${{ secrets.SSH_PORT }}
3434
passphrase: ${{ secrets.SSH_PASSPHRASE }}
35-
source: "./public,./mdx,./nginx,./static./docker-compose.yml"
35+
source: "./public,./frontend/mdx,./nginx,./frontend/static,./docker-compose.yml"
3636
target: "~/sourcedepth.com/"
3737
overwrite: true

.gitignore

Lines changed: 179 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,182 @@ sketch
4646
.tanstack
4747
_old*
4848
.vscode
49-
certbot/
49+
certbot/
50+
51+
# Created with easyignore
52+
# Created by https://www.toptal.com/developers/gitignore/api/python
53+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
54+
55+
### Python ###
56+
# Byte-compiled / optimized / DLL files
57+
__pycache__/
58+
*.py[cod]
59+
*$py.class
60+
61+
# C extensions
62+
*.so
63+
64+
# Distribution / packaging
65+
.Python
66+
build/
67+
develop-eggs/
68+
dist/
69+
downloads/
70+
eggs/
71+
.eggs/
72+
lib/
73+
lib64/
74+
parts/
75+
sdist/
76+
var/
77+
wheels/
78+
share/python-wheels/
79+
*.egg-info/
80+
.installed.cfg
81+
*.egg
82+
MANIFEST
83+
84+
# PyInstaller
85+
# Usually these files are written by a python script from a template
86+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
87+
*.manifest
88+
*.spec
89+
90+
# Installer logs
91+
pip-log.txt
92+
pip-delete-this-directory.txt
93+
94+
# Unit test / coverage reports
95+
htmlcov/
96+
.tox/
97+
.nox/
98+
.coverage
99+
.coverage.*
100+
.cache
101+
nosetests.xml
102+
coverage.xml
103+
*.cover
104+
*.py,cover
105+
.hypothesis/
106+
.pytest_cache/
107+
cover/
108+
109+
# Translations
110+
*.mo
111+
*.pot
112+
113+
# Django stuff:
114+
*.log
115+
local_settings.py
116+
db.sqlite3
117+
db.sqlite3-journal
118+
119+
# Flask stuff:
120+
instance/
121+
.webassets-cache
122+
123+
# Scrapy stuff:
124+
.scrapy
125+
126+
# Sphinx documentation
127+
docs/_build/
128+
129+
# PyBuilder
130+
.pybuilder/
131+
target/
132+
133+
# Jupyter Notebook
134+
.ipynb_checkpoints
135+
136+
# IPython
137+
profile_default/
138+
ipython_config.py
139+
140+
# pyenv
141+
# For a library or package, you might want to ignore these files since the code is
142+
# intended to run in multiple environments; otherwise, check them in:
143+
# .python-version
144+
145+
# pipenv
146+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
147+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
148+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
149+
# install all needed dependencies.
150+
#Pipfile.lock
151+
152+
# poetry
153+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
154+
# This is especially recommended for binary packages to ensure reproducibility, and is more
155+
# commonly ignored for libraries.
156+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
157+
#poetry.lock
158+
159+
# pdm
160+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
161+
#pdm.lock
162+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
163+
# in version control.
164+
# https://pdm.fming.dev/#use-with-ide
165+
.pdm.toml
166+
167+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
168+
__pypackages__/
169+
170+
# Celery stuff
171+
celerybeat-schedule
172+
celerybeat.pid
173+
174+
# SageMath parsed files
175+
*.sage.py
176+
177+
# Environments
178+
.env
179+
.venv
180+
env/
181+
venv/
182+
ENV/
183+
env.bak/
184+
venv.bak/
185+
186+
# Spyder project settings
187+
.spyderproject
188+
.spyproject
189+
190+
# Rope project settings
191+
.ropeproject
192+
193+
# mkdocs documentation
194+
/site
195+
196+
# mypy
197+
.mypy_cache/
198+
.dmypy.json
199+
dmypy.json
200+
201+
# Pyre type checker
202+
.pyre/
203+
204+
# pytype static type analyzer
205+
.pytype/
206+
207+
# Cython debug symbols
208+
cython_debug/
209+
210+
# PyCharm
211+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
212+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
213+
# and can be added to the global gitignore or merged into this file. For a more nuclear
214+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
215+
#.idea/
216+
217+
### Python Patch ###
218+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
219+
poetry.toml
220+
221+
# ruff
222+
.ruff_cache/
223+
224+
# LSP config files
225+
pyrightconfig.json
226+
227+
# End of https://www.toptal.com/developers/gitignore/api/python

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/astral-sh/ruff-pre-commit
9+
# Ruff version.
10+
rev: v0.9.9
11+
hooks:
12+
# Run the linter.
13+
- id: ruff
14+
args: [--fix]
15+
types_or: [python]
16+
# Run the formatter.
17+
- id: ruff-format
18+
types_or: [python]

backend/.python-version

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

0 commit comments

Comments
 (0)