From d71e06ea392895dbe98b9b018088a0512da76671 Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Thu, 5 Nov 2026 23:06:35 +0800 Subject: [PATCH] added ci --- .forgejo/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ .forgejo/workflows/deploy.yml | 32 ++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .forgejo/workflows/ci.yml create mode 100644 .forgejo/workflows/deploy.yml diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..8041d4b --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -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 . diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 0000000..86fdaec --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index cb35ae2..cb30564 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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:-}