2024-11-03 22:39:38 +01:00
|
|
|
name: Deploy
|
2024-11-03 22:43:57 +01:00
|
|
|
run-name: Deploying to production
|
|
|
|
on: [push]
|
2024-11-03 22:39:38 +01:00
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup SSH
|
|
|
|
env:
|
|
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
HOST1: ${{ secrets.HOST1 }}
|
|
|
|
USER: ${{ secrets.USER }}
|
|
|
|
run: |
|
|
|
|
mkdir -p ~/.ssh
|
|
|
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
ssh-keyscan -H $HOST1 >> ~/.ssh/known_hosts
|
|
|
|
|
|
|
|
- name: Deploy to first host
|
|
|
|
env:
|
|
|
|
HOST1: ${{ secrets.HOST1 }}
|
|
|
|
USER: ${{ secrets.USER }}
|
|
|
|
run: |
|
|
|
|
ssh $USER@$HOST1 'rm -rf /var/www/elia.network/html/*'
|
|
|
|
rsync -avz --delete \
|
|
|
|
--exclude '.git*' \
|
|
|
|
./ $USER@$HOST1:/var/www/elia.network/html/
|
|
|
|
|
|
|
|
- name: Reload Nginx
|
|
|
|
env:
|
|
|
|
HOST1: ${{ secrets.HOST1 }}
|
|
|
|
USER: ${{ secrets.USER }}
|
|
|
|
run: |
|
|
|
|
ssh $USER@$HOST1 'sudo systemctl reload nginx'
|