ci: build in container and deploy via rsync
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.
This commit is contained in:
2025-12-09 11:19:48 +01:00
parent 146aeb9d38
commit ffb47f3826

View File

@@ -11,14 +11,54 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
update:
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: Updating website.
- 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
@@ -27,7 +67,6 @@ jobs:
passphrase: ${{ secrets.homepage_pass }}
port: 22
script: |
cd /usr/share/webapps/homepage
git pull --force https://Alexander:${{ secrets.homepage_gitea_token }}@git.bocken.org/Alexander/homepage
npm run build
cd /usr/share/webapps/homepage/build
npm install --production --omit=dev
sudo systemctl restart homepage.service