Some checks failed
CI / build-and-deploy (push) Failing after 1m27s
Change deployment workflow to build the project in a containerized environment instead of building directly on the server. Deploy only the build artifacts via rsync, reducing server resource requirements and improving build reproducibility.
73 lines
2.0 KiB
YAML
73 lines
2.0 KiB
YAML
name: CI
|
|
|
|
# Controls when the action will run.
|
|
on:
|
|
# Triggers the workflow on push to master (including merged PRs)
|
|
push:
|
|
branches: [ master ]
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
workflow_dispatch:
|
|
|
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
jobs:
|
|
build-and-deploy:
|
|
# The type of runner that the job will run on
|
|
runs-on: ubuntu-latest
|
|
|
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 9.0.0
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: pnpm run build
|
|
|
|
- name: Deploy to server via rsync
|
|
uses: burnett01/rsync-deployments@7.0.1
|
|
with:
|
|
switches: -avzr --delete
|
|
path: build/
|
|
remote_path: /usr/share/webapps/homepage/build/
|
|
remote_host: bocken.org
|
|
remote_user: homepage
|
|
remote_key: ${{ secrets.homepage_ssh }}
|
|
remote_key_pass: ${{ secrets.homepage_pass }}
|
|
|
|
- name: Deploy package.json
|
|
uses: burnett01/rsync-deployments@7.0.1
|
|
with:
|
|
switches: -avz
|
|
path: package.json
|
|
remote_path: /usr/share/webapps/homepage/
|
|
remote_host: bocken.org
|
|
remote_user: homepage
|
|
remote_key: ${{ secrets.homepage_ssh }}
|
|
remote_key_pass: ${{ secrets.homepage_pass }}
|
|
|
|
- name: Restart service
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: bocken.org
|
|
username: homepage
|
|
key: ${{ secrets.homepage_ssh }}
|
|
passphrase: ${{ secrets.homepage_pass }}
|
|
port: 22
|
|
script: |
|
|
cd /usr/share/webapps/homepage/build
|
|
npm install --production --omit=dev
|
|
sudo systemctl restart homepage.service
|