69 lines
1.9 KiB
YAML
69 lines
1.9 KiB
YAML
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 pm cache rm
|
|
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
|
|
|
|
- name: Quay deployment
|
|
if: success()
|
|
uses: https://git.fish/quay/quay-deployment@main
|
|
with:
|
|
DEPLOY_TOKEN: ${{ secrets.QUAY_DEPLOY_TOKEN }}
|
|
SITE_ID: ${{ secrets.QUAY_SITE_ID }}
|
|
BASE_URL: https://quay.jan.run |