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