ci: build in container and deploy via rsync
Some checks failed
CI / build-and-deploy (push) Failing after 1m27s
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:
@@ -11,14 +11,54 @@ on:
|
|||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
jobs:
|
jobs:
|
||||||
# This workflow contains a single job called "build"
|
build-and-deploy:
|
||||||
update:
|
|
||||||
# The type of runner that the job will run on
|
# The type of runner that the job will run on
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
steps:
|
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
|
uses: appleboy/ssh-action@master
|
||||||
with:
|
with:
|
||||||
host: bocken.org
|
host: bocken.org
|
||||||
@@ -27,7 +67,6 @@ jobs:
|
|||||||
passphrase: ${{ secrets.homepage_pass }}
|
passphrase: ${{ secrets.homepage_pass }}
|
||||||
port: 22
|
port: 22
|
||||||
script: |
|
script: |
|
||||||
cd /usr/share/webapps/homepage
|
cd /usr/share/webapps/homepage/build
|
||||||
git pull --force https://Alexander:${{ secrets.homepage_gitea_token }}@git.bocken.org/Alexander/homepage
|
npm install --production --omit=dev
|
||||||
npm run build
|
|
||||||
sudo systemctl restart homepage.service
|
sudo systemctl restart homepage.service
|
||||||
|
|||||||
Reference in New Issue
Block a user