💚 新增Actions工作流配置
BuildImage / build-image (push) Successful in 51s Details

This commit is contained in:
李寻欢 2023-10-25 10:57:04 +08:00
parent 14250ad7ae
commit 9d46193470
3 changed files with 57 additions and 9 deletions

View File

@ -0,0 +1,53 @@
name: BuildImage
# 只打tag事件的包
on:
push:
branches:
- 'main'
jobs:
build-image:
runs-on: ubuntu-latest
container:
# 使用这个镜像不然Docker无法打包镜像
image: catthehacker/ubuntu:act-latest
steps:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: '>=1.21.0'
cache: false
- name: Checkout Code
uses: actions/checkout@v3
- name: Gen Tags
id: gen_tags
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: gitee.ltd/lxh/drone-kuboard
tags: |
type=ref,event=branch
type=sha,format=short
- name: Print Tags
run: |
echo "${{ steps.gen_tags.outputs.tags }}"
echo "----------------- labels -----------------"
echo "${{ steps.meta.outputs.labels }}"
- name: Login to Repository
uses: docker/login-action@v2
with:
registry: gitee.ltd
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
- name: Build image
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.gen_tags.outputs.tags }}
labels: ${{ steps.gen_tags.outputs.labels }}

View File

@ -2,14 +2,14 @@ FROM golang:alpine as builder
WORKDIR /builder
COPY . .
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
#ENV GO111MODULE=on
#ENV GOPROXY=https://goproxy.cn,direct
RUN go version
RUN go mod download && go build -o drone-kuboard
RUN ls -lh && chmod +x ./drone-kuboard
FROM repo.lxh.io/alpine:3.16.0 as runner
FROM code.hyxc1.com/open/alpine:3.16.0 as runner
LABEL org.opencontainers.image.authors="lxh@cxh.cn"
COPY --from=builder /builder/drone-kuboard /bin

View File

@ -1,8 +1,3 @@
### 手动打包镜像
```shell
docker build --push -t repo.lxh.io/lxh/drone-kuboard:latest .
```
### 使用方式
```yaml
kind: pipeline
@ -13,7 +8,7 @@ name: BuildContainerImage
steps:
# 更新测试环境
- name: UpdateTesting
image: repo.lxh.io/lxh/drone-kuboard
image: gitee.ltd/lxh/drone-kuboard
settings:
# 执行操作 restart | update
action: restart