ci(docker): 更新Gitea工作流以使用容器化构建环境
将Linux作业改为在golang容器中运行,简化Go环境设置步骤 移除不必要的SSH步骤,优化构建流程
This commit is contained in:
parent
fcae874fd2
commit
7965c33790
@ -23,22 +23,25 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
runs-on: vpn
|
runs-on: vpn
|
||||||
|
container:
|
||||||
|
image: golang:1.24-alpine
|
||||||
|
env:
|
||||||
|
GOARCH: amd64
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: ["1.24.3"]
|
go: ["1.24.3"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Install git and dependencies
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
|
apk add --no-cache git make docker-cli
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
run: |
|
||||||
|
git clone --depth 1 https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/${{ github.repository }}.git .
|
||||||
|
git fetch --tags
|
||||||
|
|
||||||
- name: Setup Go environment with cache
|
- name: Setup Go environment
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go }}
|
|
||||||
cache: true
|
|
||||||
cache-dependency-path: go.sum
|
|
||||||
|
|
||||||
- name: Prepare GO environment
|
|
||||||
run: |
|
run: |
|
||||||
go env -w GOPROXY=https://goproxy.cn,direct
|
go env -w GOPROXY=https://goproxy.cn,direct
|
||||||
go env -w GOPRIVATE="${{ vars.DOMAIN_OF_GITEA}}"
|
go env -w GOPRIVATE="${{ vars.DOMAIN_OF_GITEA}}"
|
||||||
@ -46,6 +49,7 @@ jobs:
|
|||||||
git config --global url."https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/".insteadOf "https://${{ vars.DOMAIN_OF_GITEA}}/"
|
git config --global url."https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/".insteadOf "https://${{ vars.DOMAIN_OF_GITEA}}/"
|
||||||
|
|
||||||
- name: Copy env file to runner container
|
- name: Copy env file to runner container
|
||||||
|
if: false # Skip this step as we're using container
|
||||||
uses: appleboy/ssh-action@v1.0.0
|
uses: appleboy/ssh-action@v1.0.0
|
||||||
with:
|
with:
|
||||||
host: ${{ env.SSH_HOST }}
|
host: ${{ env.SSH_HOST }}
|
||||||
@ -68,7 +72,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and push docker image
|
- name: Build and push docker image
|
||||||
run: |
|
run: |
|
||||||
source ${{ github.workspace }}/deploy/.env
|
if [ -f "${{ github.workspace }}/deploy/.env" ]; then
|
||||||
|
source ${{ github.workspace }}/deploy/.env
|
||||||
|
fi
|
||||||
go mod tidy
|
go mod tidy
|
||||||
make build-linux
|
make build-linux
|
||||||
make docker
|
make docker
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user