39 lines
1.1 KiB
YAML
39 lines
1.1 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pandoc
|
|
run: apt-get update && apt-get install -y pandoc
|
|
|
|
- name: Generate HTML
|
|
run: pandoc index.md -s -o index.html --template template.html
|
|
|
|
- name: Setup SSH key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
echo "Key Added"
|
|
ls ~/.ssh
|
|
|
|
- name: Deploy to server via SCP
|
|
run: |
|
|
scp -P ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
|
index.html styles.css nginx.conf \
|
|
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/var/www/ahmza.dad/
|
|
|
|
- name: Reload nginx
|
|
run: |
|
|
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
|
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \
|
|
"sudo nginx -s reload || sudo systemctl reload nginx || sudo systemctl restart nginx"
|