Switch from GitLab CI to Forgejo Actions

- Add .forgejo/workflows/ci.yaml for lint/test/type-check
- Add .forgejo/workflows/deploy.yaml for build/deploy
- Update DEPLOYMENT.md with Forgejo-specific instructions
- Remove .gitlab-ci.yml
This commit is contained in:
Bu5hm4nn
2026-03-21 19:24:36 +01:00
parent 00a68bc767
commit 46534af69e
4 changed files with 325 additions and 666 deletions

View File

@@ -0,0 +1,60 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
PYTHONUNBUFFERED: "1"
jobs:
lint:
runs-on: docker
container:
image: python:3.12-slim
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff black
- name: Run ruff
run: ruff check app tests scripts
- name: Run black
run: black --check app tests scripts
test:
runs-on: docker
container:
image: python:3.12-slim
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run tests
run: pytest -q tests
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov/
retention-days: 7
type-check:
runs-on: docker
container:
image: python:3.12-slim
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy
pip install -r requirements.txt
- name: Run mypy
run: mypy app scripts --ignore-missing-imports

View File

@@ -0,0 +1,125 @@
name: Build and Deploy
on:
push:
branches: [main]
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'production'
type: choice
options:
- production
- staging
env:
REGISTRY: ${{ vars.REGISTRY || format('{0}', github.repository_owner) }}
IMAGE_NAME: ${{ github.repository }}
IMAGE_TAG: ${{ github.sha }}
jobs:
build:
runs-on: docker
container:
image: catthehacker/ubuntu:act-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache,mode=max
- name: Output image digest
run: echo "IMAGE_DIGEST=${{ steps.meta.outputs.tags }}" >> $GITHUB_ENV
security-scan:
runs-on: docker
needs: build
container:
image: aquasec/trivy:0.61.1
steps:
- name: Scan image
run: |
trivy image --exit-code 1 \
--severity HIGH,CRITICAL \
--username "${{ github.actor }}" \
--password "${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ env.IMAGE_DIGEST }}"
deploy:
runs-on: docker
needs: [build, security-scan]
if: github.ref == 'refs/heads/main'
container:
image: python:3.12-alpine
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER || 'deploy' }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || '22' }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH || '/opt/vault-dash' }}
DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
APP_ENV: production
APP_NAME: Vault Dashboard
APP_PORT: "8000"
APP_BIND_ADDRESS: "127.0.0.1"
DEFAULT_SYMBOL: GLD
CACHE_TTL: "300"
WEBSOCKET_INTERVAL_SECONDS: "5"
NICEGUI_MOUNT_PATH: /
NICEGUI_STORAGE_SECRET: ${{ secrets.NICEGUI_STORAGE_SECRET }}
CORS_ORIGINS: ${{ secrets.CORS_ORIGINS || '*' }}
REGISTRY: ${{ env.REGISTRY }}
IMAGE_TAG: ${{ env.IMAGE_TAG }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apk add --no-cache bash openssh-client curl docker-cli docker-cli-compose
mkdir -p ~/.ssh
chmod 700 ~/.ssh
- name: Setup SSH key
run: |
printf '%s' "$DEPLOY_SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Deploy
run: |
test -n "$DEPLOY_HOST" || (echo "DEPLOY_HOST must be set" && exit 1)
bash scripts/deploy.sh
- name: Health check
if: ${{ secrets.EXTERNAL_HEALTHCHECK_URL != '' }}
run: |
python scripts/healthcheck.py "${{ secrets.EXTERNAL_HEALTHCHECK_URL }}" \
--timeout 120 \
--expect-status ok \
--expect-environment production