2024-11-23 16:41:43 +01:00
|
|
|
name: Update Website
|
|
|
|
on: [push]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
update:
|
|
|
|
runs-on: docker
|
|
|
|
container:
|
|
|
|
image: alpine:3.18
|
|
|
|
env:
|
|
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
|
|
|
|
SSH_PASSWORD: ${{ secrets.SSH_PASSWD }}
|
|
|
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
|
|
|
steps:
|
2024-11-23 16:43:16 +01:00
|
|
|
- name: Install required packages
|
|
|
|
run: |
|
|
|
|
apk add --no-cache openssh-client bash
|
2024-11-23 16:41:43 +01:00
|
|
|
- name: Set up SSH key
|
|
|
|
run: |
|
|
|
|
mkdir -p ~/.ssh
|
|
|
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
|
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
|
|
- name: Add SSH host to known_hosts
|
|
|
|
run: |
|
|
|
|
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
|
|
|
|
- name: SSH and execute command
|
|
|
|
env:
|
|
|
|
SSH_ASKPASS: /tmp/ssh-pass.sh
|
|
|
|
run: |
|
|
|
|
echo "#!/bin/bash" > /tmp/ssh-pass.sh
|
|
|
|
echo "echo $SSH_PASSWORD" >> /tmp/ssh-pass.sh
|
|
|
|
chmod +x /tmp/ssh-pass.sh
|
2024-11-24 03:08:42 +01:00
|
|
|
DISPLAY=:0 ssh -o StrictHostKeyChecking=no "app-runner@$SSH_HOST" "cd ReactLearn; git pull; docker compose restart"
|