diff --git a/.github/workflows/host-bundle.yml b/.github/workflows/host-bundle.yml new file mode 100644 index 0000000..6b29a12 --- /dev/null +++ b/.github/workflows/host-bundle.yml @@ -0,0 +1,54 @@ +name: Host Revenge Bundle + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + build-and-host: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Restore Bun cache + uses: actions/cache@v4 + with: + path: ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile --production + + - name: Build production bundle + run: bun run build + + - name: Publish bundle to hosting branch + run: | + cp dist/revenge.bundle /tmp/revenge.bundle + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + if git show-ref --verify --quiet "refs/heads/hosting"; then + git checkout hosting + git rm -rf . + else + git checkout --orphan hosting + fi + rm -rf * + cp /tmp/revenge.bundle ./revenge.bundle + git add revenge.bundle + git commit -m "Host bundle from ${GITHUB_SHA}" || true + git push --force origin hosting