Skip to content

chore: use new, text-based bun lockfile and update deps #90

chore: use new, text-based bun lockfile and update deps

chore: use new, text-based bun lockfile and update deps #90

name: Deploy to staging when push on main
on:
push:
branches:
- main
jobs:
build-and-deploy:
name: Deploy to staging because of push on main
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Cache Bun dependencies
uses: actions/cache@v3
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies with Bun
run: bun install --frozen-lockfile
- name: Build for staging with Bun and Vite
shell: bash
run: bun run build
- name: Setup SSH key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add server to known hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Copy build to server with rsync
run: rsync -avz --exclude '.git' --chown=github:www-data --chmod=Dg=rwx,Fg=rwx ./dist/* ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SERVER_PATH_STAGING }} # We set directory (D) and files (F) permission for group www-data to rwx so that the same users can overwrite later
- name: Relaunch nginx on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: sudo systemctl restart nginx.service