website/.gitea/workflows/deploy.yaml

37 lines
1.1 KiB
YAML
Raw Normal View History

2024-11-15 22:30:12 +01:00
name: Deploy to production
2024-11-03 23:17:24 +01:00
run-name: Deploying to production
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
2024-11-03 23:26:02 +01:00
container:
2024-11-03 23:29:14 +01:00
image: alpine
2024-11-03 23:17:24 +01:00
steps:
2024-11-04 00:10:00 +01:00
- name: Install packages
2024-11-03 23:26:02 +01:00
run: |
2024-11-03 23:38:10 +01:00
apk add --no-cache git openssh-client nodejs
- name: Checkout code
uses: actions/checkout@v3
2024-11-03 23:17:24 +01:00
- 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
2024-11-03 23:52:26 +01:00
- name: Deploy to host
2024-11-03 23:17:24 +01:00
env:
HOST1: ${{ secrets.HOST1 }}
USER: ${{ secrets.USER }}
run: |
2024-11-05 15:58:00 +01:00
echo "Deploying..."
echo "Removing old files..."
2024-11-03 23:17:24 +01:00
ssh $USER@$HOST1 'rm -rf /var/www/elia.network/html/*'
2024-11-05 15:58:00 +01:00
echo "Copying new files..."
2024-11-03 23:43:10 +01:00
scp -r . $USER@$HOST1:/var/www/elia.network/html
2024-11-05 15:58:00 +01:00
echo "Deployment done!"
2024-11-03 23:30:50 +01:00
ssh $USER@$HOST1 'rm -r /var/www/elia.network/html/.git*'