-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (59 loc) · 1.89 KB
/
deploy.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Deploy with Commit Hash
on:
push:
branches:
- deploy
jobs:
linter:
runs-on: ubuntu-latest
steps:
- run:
sudo apt-get install libwebp-dev
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23.1'
cache: false
- name: Set go env
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOBIN=$(go env GOBIN)" >> $GITHUB_ENV
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: run golangci-lint
run: golangci-lint run --new-from-rev origin/deploy
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.23.1'
- name: Test
run: go test -v ./...
deploy:
needs: [tests, linter]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get Commit Hash
id: vars
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Deploy to server via SSH
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Using Commit Hash: ${{ env.COMMIT_HASH }}"
cd back
echo "Pulling latest code from deploy branch..."
git pull origin deploy
echo "Running 'make all'..."
make all
echo "Building Docker containers with commit hash..."
COMMIT_HASH=${{ env.COMMIT_HASH }} docker compose build --build-arg COMMIT_HASH=${{ env.COMMIT_HASH }}
echo "Starting Docker containers..."
COMMIT_HASH=${{ env.COMMIT_HASH }} docker compose up -d