Skip to content

Merge branch '3D'

Merge branch '3D' #38

Workflow file for this run

name: Deploy to prod when tag
on:
push:
tags:
- "*"
jobs:
bump-version:
name: Bump Version
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Bump version in package.json to ${{ github.ref_name }}
run: sed -E -i 's/"version":[[:space:]]"[0-9]+.[0-9]+.[0-9]+"/"version":\ "${{ github.ref_name }}"/g' ./package.json
- name: Commit and push updated package.json
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: "chore: bump version to ${{ github.ref_name }}"
commit_user_name: Adrien Carpentier
commit_user_email: me@adriencarpentier.com
commit_author: Adrien Carpentier <me@adriencarpentier.com>
build-and-deploy:
name: Deploy to prod because of tag ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: bump-version
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Pull latest changes
run: git pull origin main
- name: Bump version in package.json to ${{ github.ref_name }}
run: sed -E -i 's/"version":[[:space:]]"[0-9]+.[0-9]+.[0-9]+"/"version":\ "${{ github.ref_name }}"/g' ./package.json
- name: Commit and push updated package.json
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: "chore: bump version to ${{ github.ref_name }}"
commit_user_name: Adrien Carpentier
commit_user_email: me@adriencarpentier.com
commit_author: Adrien Carpentier <me@adriencarpentier.com>
- 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 production 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_PROD }} # 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