Compare commits
52 Commits
4c1a905088
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bea436058d | ||
|
|
000f34a059 | ||
|
|
93837e0248 | ||
|
|
e90fa00227 | ||
|
|
bd18f32670 | ||
|
|
6e2e0f0ed0 | ||
|
|
42becfe8b0 | ||
|
|
b385dfb0ec | ||
|
|
925e346df3 | ||
|
|
3b1c6f4ee9 | ||
|
|
e4364224bd | ||
|
|
1db170150f | ||
|
|
8b5d44399e | ||
|
|
062b40cf13 | ||
|
|
f130badb33 | ||
|
|
4c748b20e3 | ||
|
|
8714af1ed6 | ||
|
|
ac450cfa29 | ||
|
|
76a838ef4f | ||
|
|
876b4ed497 | ||
|
|
4e1822bafa | ||
|
|
212099a265 | ||
|
|
8edf753f47 | ||
|
|
50aad7aaed | ||
|
|
54346e072d | ||
|
|
4154c807b1 | ||
|
|
0b9e58896f | ||
|
|
f61941608b | ||
|
|
2ea535146f | ||
|
|
9694ae0289 | ||
|
|
6f4be9695f | ||
|
|
05e25ab63e | ||
|
|
78c839f3a7 | ||
|
|
02d16f9612 | ||
|
|
d21cd672a6 | ||
|
|
4c3670a43c | ||
|
|
4a0b8404f1 | ||
| 41b2458f0d | |||
| ec019c24ab | |||
| e901a905c6 | |||
| 4d593c7e74 | |||
| 4b757dc60c | |||
| 69cbfd9c2e | |||
| dfcea9ec22 | |||
| a5d926df13 | |||
| 68a8f4e71b | |||
| dfb786c0a7 | |||
| 64d90a5a1c | |||
| ae1cfb214a | |||
| b7a0a9399e | |||
| 1dbd408bb0 | |||
| dcd2545360 |
@@ -4,20 +4,22 @@ on: [push]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Explore-Gitea-Actions:
|
Explore-Gitea-Actions:
|
||||||
runs-on: gitea-runner
|
runs-on: nodejs
|
||||||
container:
|
container:
|
||||||
image: alpine:gitea-runner
|
image: node:gitea-runner
|
||||||
volumes:
|
volumes:
|
||||||
- data:/var/data
|
- /var/data/zApps:/var/data/zApps
|
||||||
- deploy:/var/deploy
|
- /var/data/zUser/apps:/var/data/zUser/apps
|
||||||
- /usr/bin/docker:/usr/bin/docker
|
- /var/data/zApps/bin/docker/docker:/usr/bin/docker
|
||||||
steps:
|
steps:
|
||||||
- run: echo "PATH=/var/data/zApps/go/bin:$PATH" >> $GITHUB_ENV
|
- run: echo "GOPATH=/var/data/zUser/apps/go" >> $GITHUB_ENV
|
||||||
|
- run: echo "GOPROXY=https://goproxy.cn,direct" >> $GITHUB_ENV
|
||||||
|
- run: echo "PATH=/var/data/zApps/bin:/var/data/zUser/apps/node/bin:/var/data/zUser/apps/go/bin:/var/data/zApps/go/bin:$PATH" >> $GITHUB_ENV
|
||||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v6
|
uses: https://git.0orz.top/actions/checkout@v6.0.2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
@@ -28,8 +30,10 @@ jobs:
|
|||||||
- name: Check go version
|
- name: Check go version
|
||||||
run: |
|
run: |
|
||||||
go version
|
go version
|
||||||
- name: Run golangci-lint
|
# - name: Run golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v9
|
# run: |
|
||||||
|
# cd ${{ gitea.workspace }}
|
||||||
|
# golangci-lint run ./...
|
||||||
- name: Tests
|
- name: Tests
|
||||||
run: |
|
run: |
|
||||||
cd ${{ gitea.workspace }}
|
cd ${{ gitea.workspace }}
|
||||||
@@ -44,23 +48,23 @@ jobs:
|
|||||||
docker --version
|
docker --version
|
||||||
- name: Login to Harbor
|
- name: Login to Harbor
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login localhost:8180 -u "${{ secrets.HARBOR_USERNAME }}" --password-stdin
|
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login harbor.0orz.top -u "${{ secrets.HARBOR_USERNAME }}" --password-stdin
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
cd ${{ gitea.workspace }}
|
cd ${{ gitea.workspace }}
|
||||||
docker build -t localhost:8180/go-example/go-example:${{ gitea.sha }} .
|
docker build -t harbor.0orz.top/go-example/go-example:${{ gitea.sha }} .
|
||||||
- name: Push Docker image to local registry
|
- name: Push Docker image to local registry
|
||||||
run: |
|
run: |
|
||||||
docker push localhost:8180/go-example/go-example:${{ gitea.sha }}
|
docker push harbor.0orz.top/go-example/go-example:${{ gitea.sha }}
|
||||||
- name: Update manifest and Push to Git
|
- name: Update manifest and Push to Git
|
||||||
run: |
|
run: |
|
||||||
# 使用 kustomize 或 sed 修改镜像版本
|
# 使用 kustomize 或 sed 修改镜像版本
|
||||||
sed -i "s|image: .*:.*|image: localhost:8180/go-example/go-example:${{ gitea.sha }}|g" deployment.yaml
|
sed -i "s|image: .*:.*|image: harbor.0orz.top/go-example/go-example:${{ gitea.sha }}|g" kustomize/deployment.yaml
|
||||||
|
|
||||||
# 配置 Git 并提交回仓库
|
# 配置 Git 并提交回仓库
|
||||||
git config --global user.name "Gitea Action"
|
git config --global user.name "Gitea Action"
|
||||||
git config --global user.email "action@gitea.io"
|
git config --global user.email "action@gitea.io"
|
||||||
git add deployment.yaml
|
git add kustomize/deployment.yaml
|
||||||
git commit -m "chore: update image to ${{ gitea.sha }} [skip ci]"
|
git commit -m "chore: update image to ${{ gitea.sha }} [skip ci]"
|
||||||
git push origin main
|
git push origin main
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
|
|||||||
12
clusters/app/flux-deploy.sh
Executable file
12
clusters/app/flux-deploy.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
USER_NAME=Zpekii
|
||||||
|
BRANCH=main
|
||||||
|
URL=https://git.0orz.top/Zpekii/go-example.git
|
||||||
|
|
||||||
|
flux bootstrap git \
|
||||||
|
--url=$URL \
|
||||||
|
--branch=$BRANCH \
|
||||||
|
--username=$USER_NAME \
|
||||||
|
--token-auth=true \
|
||||||
|
--path=./clusters/app
|
||||||
@@ -20,7 +20,7 @@ metadata:
|
|||||||
namespace: flux-system
|
namespace: flux-system
|
||||||
spec:
|
spec:
|
||||||
interval: 10m0s
|
interval: 10m0s
|
||||||
path: ./
|
path: ./clusters/app
|
||||||
prune: true
|
prune: true
|
||||||
sourceRef:
|
sourceRef:
|
||||||
kind: GitRepository
|
kind: GitRepository
|
||||||
17
clusters/app/go-example-kustomization.yaml
Normal file
17
clusters/app/go-example-kustomization.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: go-example
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 30m0s
|
||||||
|
path: ./kustomize
|
||||||
|
prune: true
|
||||||
|
retryInterval: 2m0s
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: go-example
|
||||||
|
targetNamespace: helloapp
|
||||||
|
timeout: 3m0s
|
||||||
|
wait: true
|
||||||
11
clusters/app/go-example-source.yaml
Normal file
11
clusters/app/go-example-source.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
apiVersion: source.toolkit.fluxcd.io/v1
|
||||||
|
kind: GitRepository
|
||||||
|
metadata:
|
||||||
|
name: go-example
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 1m0s
|
||||||
|
ref:
|
||||||
|
branch: main
|
||||||
|
url: https://git.0orz.top/Zpekii/go-example
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: helloapp
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: go-example
|
name: go-example
|
||||||
@@ -28,15 +33,15 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: go-example
|
- name: go-example
|
||||||
image: localhost:8180/go-example/go-example:0b2c48ee261873d5a5b2146f424e2a68ce33d4da
|
image: harbor.0orz.top/go-example/go-example:000f34a0591306e686e8cf06bf131449eb30b028
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "128Mi"
|
memory: "5Mi"
|
||||||
cpu: "500m"
|
cpu: "10m"
|
||||||
limits:
|
limits:
|
||||||
memory: "128Mi"
|
memory: "50Mi"
|
||||||
cpu: "500m"
|
cpu: "100m"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8800
|
- containerPort: 8800
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
@@ -52,7 +57,7 @@ spec:
|
|||||||
name: go-example-config
|
name: go-example-config
|
||||||
- name: helloapp-test-key
|
- name: helloapp-test-key
|
||||||
secret:
|
secret:
|
||||||
secretName: helloapp-test-key
|
secretName: helloapp-test-key # 需要事先创建该 Secret
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
@@ -64,4 +69,4 @@ data:
|
|||||||
server:
|
server:
|
||||||
port: 8800
|
port: 8800
|
||||||
certs:
|
certs:
|
||||||
testKeyPath: /certs/test.key
|
testKeyPath: /certs/test.key
|
||||||
Reference in New Issue
Block a user