added ci
All checks were successful
Deploy Media Kit / deploy (push) Successful in 13s

This commit is contained in:
liyunze 2026-11-05 23:06:35 +08:00
parent 36ea6bee96
commit d71e06ea39
3 changed files with 62 additions and 1 deletions

29
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,29 @@
name: CI
# pull_request_target always runs this file from the base branch. A pull request
# cannot replace these steps, which is what `pull_request` would allow after
# someone clicks Approve on a fork.
#
# Forks are not built until a maintainer adds the `ci` label. Review Dockerfile,
# the frontend package files, and the backend Cargo files before adding it. New
# commits do not reuse that label; remove it and add it again after reviewing.
on:
pull_request_target:
types: [opened, synchronize, reopened, labeled]
jobs:
check:
if: |
forgejo.event.pull_request.head.repo.full_name == forgejo.repository ||
(forgejo.event.action == 'label_updated' && forgejo.event.label.name == 'ci')
runs-on: native
steps:
- name: Checkout pull request
uses: https://data.forgejo.org/actions/checkout@v4
with:
repository: ${{ forgejo.event.pull_request.head.repo.full_name }}
ref: ${{ forgejo.event.pull_request.head.sha }}
persist-credentials: false
- name: Build application image
run: docker build --pull --tag media-kit:ci .

View file

@ -0,0 +1,32 @@
name: Deploy Media Kit
on:
push:
branches:
- main
jobs:
deploy:
runs-on: native
steps:
- name: Checkout code
uses: https://data.forgejo.org/actions/checkout@v4
- name: Create .env from secrets
run: |
cat > .env << EOF
TWITCH_CLIENT_ID=${{ secrets.TWITCH_CLIENT_ID }}
TWITCH_CLIENT_SECRET=${{ secrets.TWITCH_CLIENT_SECRET }}
TWITCH_LOGIN=${{ secrets.TWITCH_LOGIN }}
ADMIN_USER=${{ secrets.ADMIN_USER }}
ADMIN_PASSWORD=${{ secrets.ADMIN_PASSWORD }}
EOF
chmod 600 .env
- name: Build and deploy
run: |
echo "Starting Docker Compose..."
docker compose up -d --build --force-recreate --remove-orphans
echo "Cleaning up..."
docker image prune -f

View file

@ -2,7 +2,7 @@ services:
media-kit:
build: .
ports:
- "3000:3000"
- "8081:3000"
environment:
TWITCH_CLIENT_ID: ${TWITCH_CLIENT_ID:-}
TWITCH_CLIENT_SECRET: ${TWITCH_CLIENT_SECRET:-}