Files
singapore_rain_radar/.gitea/workflows/deploy.yaml
2024-08-18 20:26:45 +08:00

38 lines
1.2 KiB
YAML

name: Deploy
run-name: deploy frontned to remote server
on: [push]
jobs:
copy:
runs-on: ubuntu-latest
steps:
- name: Test if destination directory variable is set
if: ${{vars.DESTINATION_DIR == '' }}
run: exit 1
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/remote.key
chmod 600 ~/.ssh/remote.key
cat >>~/.ssh/config <<END
Host remote
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/remote.key
StrictHostKeyChecking no
env:
SSH_USER: ${{ secrets.USERNAME }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.HOST }}
- name: Setup rsync
run: apt-get update && apt-get install rsync -y
- name: Checkout code
uses: actions/checkout@v2
- name: Upload files
run: rsync -rvp --chown=quentin:users --chmod=777 --exclude=.gitea --exclude=.git ${{ vars.RSYNC_ARGS }} . remote:${{ vars.DESTINATION_DIR }}
- name: Run container
run: ssh remote 'cd ${{ vars.DESTINATION_DIR }} && make run'