From da303c082a1c1ea92f5b1acffe48a7d3124b05c9 Mon Sep 17 00:00:00 2001 From: KartoffelChipss <4+kartoffelchipss@noreply.git.fish> Date: Fri, 1 May 2026 21:00:28 +0000 Subject: [PATCH] Add deploy gitea workflow --- .gitea/workflows/deploy.yml | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 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..00382a1 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,59 @@ +name: Deploy +on: + push: + branches: + - main + +jobs: + deploy: + name: Build and Deploy + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' + + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Build project + run: bun run build + + - name: Deploy to pages branch + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_SERVER: ${{ gitea.server_url }} + REPO: ${{ gitea.repository }} + ACTOR: ${{ gitea.actor }} + run: | + # Configure git + git config --global user.name "gitea-actions[bot]" + git config --global user.email "gitea-actions[bot]@users.noreply.gitea.io" + + # Save dist outside the working tree before switching branches + TMP_DIR=$(mktemp -d) + cp -r ./dist/. "$TMP_DIR/" + + # Create a fresh orphan pages branch (no history, clean slate every deploy) + git checkout --orphan pages + git rm -rf . >/dev/null 2>&1 || true + find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} + + + # Copy build output into the branch root + cp -r "$TMP_DIR/." . + + git add -A + git commit -m "Deploy: ${{ gitea.sha }}" || { echo "Nothing to commit"; exit 0; } + + # Force-push to pages branch + git push --force "https://${ACTOR}:${GITEA_TOKEN}@${GITEA_SERVER#https://}/${REPO}.git" pages \ No newline at end of file