Skip to content

build: update dependencies #71

build: update dependencies

build: update dependencies #71

name: Deploy to staging when push on main
on:
push:
branches:
- main
jobs:
deploy-staging:
name: Deploy to staging because of push on main
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
name: Install Bun
with:
bun-version: latest
- name: Install dependencies with Bun
shell: bash
run: bun install
- name: Build for staging with Bun and Vite
shell: bash
run: bun run build
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
name: id_rsa
known_hosts: ${{ secrets.SSH_HOST }}
- 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