-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (37 loc) · 1.13 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Build and deploy on Server
on:
push:
branches:
- main
env:
DIRECTORY: "${{ vars.DIRECTORY }}/${{ github.event.repository.name }}"
jobs:
build-and-deploy:
environment: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Confirm host key
run: ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
- name: Deploy on Server
run: |
ssh -t "${{ secrets.SERVER_USER }}"@"${{ secrets.SERVER_HOST }}" << EOF
if [ -d "$DIRECTORY" ]; then
rm -rf $DIRECTORY
fi
mkdir -p $DIRECTORY
cd $DIRECTORY
git clone [email protected]:${{ github.repository }}.git .
git submodule init
git submodule update
echo "${{ secrets.ENVS }}" > .env
sh deploy.sh
rm -rf $DIRECTORY
EOF