79 lines
2.4 KiB
YAML
79 lines
2.4 KiB
YAML
name: Deploy to Web Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
# runs-on: WebDeployment
|
|
runs-on: 3900x
|
|
container:
|
|
image: docker.io/node:24-bookworm
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pnpm
|
|
uses: https://github.com/pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- name: Install Node.js
|
|
uses: https://github.com/actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
cache: 'pnpm'
|
|
|
|
# - uses: https://github.com/denoland/setup-deno@v2
|
|
# with:
|
|
# deno-version: vx.x.x
|
|
# cache: true
|
|
|
|
- name: Install SSH key
|
|
uses: https://github.com/shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.SSH_KEY }}
|
|
name: aria-coffee-deploy # optional
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
if_key_exists: fail
|
|
|
|
- run: pnpm install
|
|
# - run: deno install
|
|
|
|
- name: Build website
|
|
run: pnpm run build-action
|
|
# run: deno run build-action
|
|
|
|
- name: Create folder if not exists
|
|
continue-on-error: true
|
|
run: |
|
|
ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "mkdir -p /var/www/Aria/"
|
|
|
|
- name: Clear old backup
|
|
continue-on-error: true
|
|
run: |
|
|
ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "[ -d "/var/www/Aria/dist-old" ] && rm -r /var/www/Aria/dist-old"
|
|
|
|
- name: Backup current install
|
|
continue-on-error: true
|
|
run: |
|
|
ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "[ -d "/var/www/Aria/dist" ] && mv /var/www/Aria/dist /var/www/Aria/dist-old"
|
|
|
|
- name: Copy over new build-action
|
|
run: |
|
|
scp -i ~/.ssh/aria-coffee-deploy -rC ./dist ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }}:/var/www/Aria
|
|
|
|
# - name: install rsync
|
|
# run: |
|
|
# apt-get update -y && apt-get install rsync -y
|
|
|
|
# - name: rsync deployments
|
|
# run: |
|
|
# rsync -avzrP -e "ssh -i ~/.ssh/aria-coffee-deploy" ./dist ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }}:/var/www/Aria
|
|
|
|
|
|
- name: Set permissions on the deployed files
|
|
run: |
|
|
ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "chmod -R 755 /var/www/Aria/dist"
|