-
Notifications
You must be signed in to change notification settings - Fork 28
68 lines (58 loc) · 1.88 KB
/
Copy pathdeploy.yml
File metadata and controls
68 lines (58 loc) · 1.88 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
name: SmokeAliyunECS
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
if: github.repository == 'mojocn/unchain'
runs-on: ubuntu-latest
environment: production
env:
GIT_SHA: ${{ github.sha }}
GIT_REF_NAME: ${{ github.ref_name }}
GIT_REPO: ${{ github.repository }}
steps:
- name: Skip Smoke Run
run: |
if [ -z "${{ secrets.SSH_KEY }}" ]; then
echo "SSH_KEY secret is not set or empty."
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
- name: install ssh-scp
run: sudo apt-get install -y openssh-client
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23"
- name: Get build time
id: build-time
run: echo "buildTime=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
- name: Build
env:
CGO_ENABLED: "1"
GOARCH: "amd64"
GIT_SHA: ${{ github.sha }}
GIT_REF_NAME: ${{ github.ref_name }}
GIT_REPO: ${{ github.repository }}
run: |
echo "Building Go application with gitHash=${{ env.gitHash }} and buildTime=${{ env.buildTime }}"
go build -ldflags="-X 'main.gitHash=${{ github.sha }}' -X 'main.buildTime=${{ env.buildTime }}'" -o unchain .
- name: Deploy to ECS A
env:
SSH_HOST: ${{ vars.HOST_A }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
ENV_VARS: ${{ vars.ENV_VARS }}
run: bash .github/workflows/deploy.sh
# add more server to deploy
- name: Deploy to ECS B
env:
SSH_HOST: ${{ vars.HOST_B }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
ENV_VARS: ${{ vars.ENV_FILE }}
run: bash .github/workflows/deploy.sh