Skip to content

Commit 402e6bb

Browse files
authored
Merge pull request #116 from jiaozifs/deployment/test
deployment/test
2 parents 3598ed6 + 8ff1d73 commit 402e6bb

File tree

9 files changed

+93
-13
lines changed

9 files changed

+93
-13
lines changed

.github/workflows/basic_check.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
name: basic-check
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- '**'
4+
workflow_call:
105

116
jobs:
127
check:
@@ -35,6 +30,15 @@ jobs:
3530
- name: end-of-file-check
3631
uses: njgibbon/fend@main
3732

33+
- uses: azure/setup-helm@v3
34+
with:
35+
version: 'v3.14.0'
36+
id: install
37+
38+
- name: Helm lint
39+
run: |
40+
helm lint --strict chart
41+
3842
- name: Lint
3943
run: |
4044
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -d -b $(go env GOPATH)/bin v1.55.1

.github/workflows/deployment.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: test
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
DOCKERHUB_USERNAME:
7+
required: true
8+
DOCKERHUB_TOKEN:
9+
required: true
10+
KUBECONTENT:
11+
required: true
12+
jobs:
13+
deployment:
14+
if: ${{ startsWith(github.ref, 'refs/heads/deployment/') || github.ref == 'refs/heads/main' }}
15+
runs-on: [self-hosted]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: '1.20.9'
23+
cache: true
24+
25+
- name: install deps
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get -o Acquire::Retries=3 install make gcc git curl wget -y
29+
30+
- name: Build
31+
env:
32+
GOPROXY: "https://proxy.golang.org,direct"
33+
GO111MODULE: "on"
34+
run: |
35+
make build
36+
37+
- name: Get version
38+
id: version
39+
run: |
40+
if [[ -n "$GITHUB_REF" && "$GITHUB_REF" == "refs/tags/"* ]]; then
41+
echo "tag version"
42+
echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}"
43+
else
44+
echo "commit version"
45+
echo "::set-output name=version::${{ github.sha }}"
46+
fi
47+
48+
- name: Build and push
49+
run: |
50+
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
51+
make docker TAG=${{ steps.version.outputs.version }}
52+
53+
- name: Deploy
54+
uses: WyriHaximus/github-action-helm3@v3
55+
with:
56+
exec: helm upgrade jiaozifs-api --install ./chart --wait --atomic --timeout 2m --namespace jiaozifs --set-string log_level=debug --set-string db='${{secrets.DBURL}}' --set-string tag=${{ steps.version.outputs.version }}
57+
kubeconfig: ${{ secrets.KUBECONTENT }}
58+
overrule_existing_kubeconfig: "true"

.github/workflows/flow.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'deployment/**'
8+
pull_request:
9+
branches:
10+
- '**'
11+
12+
jobs:
13+
check:
14+
uses: ./.github/workflows/basic_check.yml
15+
test:
16+
uses: ./.github/workflows/test.yml
17+
deployment:
18+
needs:
19+
- test
20+
- check
21+
uses: ./.github/workflows/deployment.yml
22+
secrets: inherit

.github/workflows/test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
name: test
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- '**'
4+
workflow_call:
105

116
jobs:
127
test:
File renamed without changes.

charts/templates/deployment.yaml renamed to chart/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
spec:
1818
containers:
1919
- name: jiaozifs-backend
20-
image: gitdatateam/jzfs:latest
20+
image: gitdatateam/jzfs:{{ .Values.tag }}
2121
imagePullPolicy: Always
2222
args: ["--db {{ .Values.db }} --log-level {{ .Values.log_level }} --bs_path {{ .Values.home_path }}/data --listen http://0.0.0.0:{{ .Values.port }} --config {{ .Values.home_path }}/config.yaml"]
2323
ports:
File renamed without changes.
File renamed without changes.

charts/values.yaml renamed to chart/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ port: 34913
88
ingress_name: nginx
99
log_level: info
1010
claim_name: jiaozifs-home
11+
tag: latest

0 commit comments

Comments
 (0)