-
Notifications
You must be signed in to change notification settings - Fork 6
41 lines (33 loc) · 1.26 KB
/
deploy-backend.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
name: Deploy on Backend Development Branch Changes
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Configure Docker to Use Non-HTTPS Registry
run: |
echo '{ "insecure-registries" : ["${{ secrets.DOCKER_REGISTRY }}"] }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
- name: Check Docker Daemon Configuration
run: cat /etc/docker/daemon.json
- name: Build Docker Image
run: |
docker build -t ${{ secrets.DOCKER_REGISTRY }}/morak_backend:${{ github.sha }} -f ./app/backend/Dockerfile .
- name: Push Docker Image to Registry
run: |
docker push ${{ secrets.DOCKER_REGISTRY }}/morak_backend:${{ github.sha }}
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy to Server
run: |
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "
cd morak
./be-deploy.sh ${{ github.sha }}
"