-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (90 loc) · 2.85 KB
/
docker-build.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Build and Push Docker Image
on:
push:
branches: [ main ]
paths-ignore: [ '**.md','docker-compose.yml' ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
goarch: amd64
- arch: arm64
goarch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build binary
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -o proxy-go-${{ matrix.arch }}
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: proxy-go-${{ matrix.arch }}
path: proxy-go-${{ matrix.arch }}
docker:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: woodchen
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create Docker build context
run: |
mkdir -p docker-context
cp Dockerfile docker-context/
cp proxy-go-amd64/proxy-go-amd64 docker-context/proxy-go.amd64
cp proxy-go-arm64/proxy-go-arm64 docker-context/proxy-go.arm64
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: docker-context
platforms: linux/amd64,linux/arm64
push: true
tags: |
woodchen/proxy-go:latest
- name: Execute deployment commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: root
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
docker pull woodchen/proxy-go:latest
docker stop proxy-go || true
docker rm proxy-go || true
docker compose -f /opt/1panel/docker/compose/proxy-go/docker-compose.yml up -d
- name: Execute deployment commands-SH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST_SH }}
username: root
key: ${{ secrets.SERVER_SSH_KEY_SH }}
script: |
docker pull woodchen/proxy-go:latest
docker stop proxy-go || true
docker rm proxy-go || true
docker compose -f /opt/1panel/docker/compose/proxy-go/docker-compose.yml up -d