Maxime Delporte 89f22f491e
All checks were successful
Deploying Website / build (push) Successful in 2m54s
Updating CI.
2025-04-21 09:25:22 -03:00

49 lines
1.5 KiB
YAML

name: Deploying Website
run-name: ${{ gitea.actor }} is testing out Deploying Website
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Updating apt get
run: apt update && apt upgrade -y
- name: Install rsync
run: apt install rsync -y
- name: Clone the repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install @angular/cli
run: npm install -g @angular/cli
- name: Install dependencies
run: npm install
- name: Build Angular app
run: ng build
- name: Add host key to known_hosts
run: |
mkdir -p ~/.ssh
echo "${{ secrets.RUNNER_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -p ${{ secrets.SERVER_PORT }} -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- name: Test SSH connection
run: ssh -v -p ${{ secrets.SERVER_PORT }} -i ~/.ssh/id_rsa ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} 'echo "SSH connection successful"'
- name: Deploy to server
run: |
ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "rm -rf /var/www/todo.hstr.fr/*"
rsync -avz -e 'ssh -p ${{ secrets.SERVER_PORT }}' --delete ./dist/todo-app-angular/* ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/var/www/todo.hstr.fr