29 lines
904 B
YAML
29 lines
904 B
YAML
|
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:
|
||
|
- 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
|
||
|
DISPLAY=:0 ssh -o StrictHostKeyChecking=no "root@$SSH_HOST" "cd ReactLearn; git pull; docker compose restart"
|