Rename and update deployment workflow
Some checks failed
Deploy to Server / deploy (push) Failing after 4s

- Renames the workflow from `CI` to `Deploy to Server`.
- Adds SSH key setup and deployment steps.
- Uses secrets for SSH key, host, user, and port.
- Pulls the latest changes from the origin master branch.
- Executes the build script after pulling changes.
This commit is contained in:
Roger Gonzalez 2025-05-14 20:03:07 -03:00
parent 0453f65a3d
commit 72f8d98cec
Signed by: rogs
GPG Key ID: C7ECE9C6C36EC2E6

View File

@ -1,4 +1,4 @@
name: CI
name: Deploy to Server
on:
push:
@ -6,9 +6,28 @@ on:
- master
jobs:
say-hello:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Greet
run: echo "CI is working on Gitea!"
- name: Checkout code
uses: actions/checkout@v3
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
chmod 700 ~/.ssh
ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
- name: Deploy via SSH
run: |
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" 'cd /home/rogsme/repo && git stash && git pull --force origin master && ./build.sh'
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PORT: ${{ secrets.SSH_PORT }}