From 669c2027b9ea82a1c64622b7a9c9133d3473da00 Mon Sep 17 00:00:00 2001 From: Ivan Rezchikov Date: Tue, 15 Sep 2026 20:21:08 +0300 Subject: [PATCH] ci: migrate to Gitea Workflows --- .gitea/workflows/deploy.yml | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..33f889d --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,81 @@ +name: Build and Deploy + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + lint-frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + + - name: Install dependencies + run: bun install + + - name: Lint frontend + run: bun run lint + + build-frontend: + needs: lint-frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + + - name: Install dependencies + run: bun install + + - name: Build frontend + run: bun run build + + - name: Build and push Docker image + run: | + docker build -t ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_IMAGE }}:latest . + docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_IMAGE }}:latest + + deploy: + needs: build-frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup SSH key + run: | + mkdir -p ~/.ssh + cat > ~/.ssh/deploy_key << 'EOF' + ${{ secrets.DEPLOY_SSH_KEY }} + EOF + chmod 600 ~/.ssh/deploy_key + ssh-keyscan -p ${{ vars.DEPLOY_PORT }} ${{ vars.DEPLOY_HOST }} >> ~/.ssh/known_hosts 2>/dev/null || true + + - name: Create .env file on server + run: | + ssh -i ~/.ssh/deploy_key -p ${{ vars.DEPLOY_PORT }} ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} \ + "cat > /opt/app/.env" << 'ENVEOF' + PUBLIC_URL=${{ vars.PUBLIC_URL }} + DATABASE_URL=${{ secrets.DATABASE_URL }} + KOTOSOFT_ID_API_PUBLIC_URL=${{ vars.KOTOSOFT_ID_API_PUBLIC_URL }} + KOTOSOFT_ID_API_URL=${{ vars.KOTOSOFT_ID_API_URL }} + KOTOSOFT_CLIENT_ID=${{ secrets.KOTOSOFT_CLIENT_ID }} + KOTOSOFT_CLIENT_SECRET=${{ secrets.KOTOSOFT_CLIENT_SECRET }} + JWT_SECRET=${{ secrets.JWT_SECRET }} + MINIO_ACCESS_KEY=${{ secrets.MINIO_ACCESS_KEY }} + MINIO_SECRET_KEY=${{ secrets.MINIO_SECRET_KEY }} + MINIO_PUBLIC_URL=${{ vars.MINIO_PUBLIC_URL }} + LETSENCRYPT_HOST=${{ vars.DOMAIN }} + LETSENCRYPT_EMAIL=${{ vars.LETSENCRYPT_EMAIL }} + DOMAIN=${{ vars.DOMAIN }} + ENVEOF + + - name: Deploy with Docker Compose + run: | + ssh -i ~/.ssh/deploy_key -p ${{ vars.DEPLOY_PORT }} ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} \ + "cd /opt/app && docker compose -p ${{ vars.DOCKER_COMPOSE_PROJECT }} up -d" \ No newline at end of file