-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (64 loc) · 1.94 KB
/
Copy pathdeploy_dev.yml
File metadata and controls
77 lines (64 loc) · 1.94 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Deploy Dev
on:
push:
branches:
- develop
env:
ARTIFACT_BUILD_RESULT: artifact-build-result
BUILD_FILE_NAME: proxy-server
WORKING_DIR_SERVER: /home/thaibx/proxy-server
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: go build -o ${{ env.BUILD_FILE_NAME }} ./cmd/main.go
- name: Test
run: go test ./...
- name: Vet
run: go vet ./...
- uses: actions/upload-artifact@v2
with:
name: ${{ env.ARTIFACT_BUILD_RESULT }}
path: ${{ env.BUILD_FILE_NAME }}
deploy:
needs:
- build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout/@v2
- name: Combine Environments
env:
DEV_ENV_FILE: ${{ secrets.ENV_DEV}}
run: echo $DEV_ENV_FILE | base64 --decode > .env
- uses: actions/download-artifact@v2
with:
name: ${{ env.ARTIFACT_BUILD_RESULT }}
- name: SCP files
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST_DEV }}
username: ${{ secrets.SSH_USER_DEV }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
source: "proxy-server,.env,deployment/deploy.sh"
target: ${{ env.WORKING_DIR_SERVER }}
- name: SSH to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST_DEV }}
username: ${{ secrets.SSH_USER_DEV }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: bash ${{ env.WORKING_DIR_SERVER}}/deployment/deploy.sh