mirror of
https://github.com/linshenkx/prompt-optimizer.git
synced 2026-05-20 09:26:59 +08:00
55 lines
1.4 KiB
YAML
55 lines
1.4 KiB
YAML
name: Docker Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
- 'docs/**'
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
- 'docs/**'
|
|
|
|
env:
|
|
REGISTRY: docker.io
|
|
IMAGE_NAME: linshen/prompt-optimizer
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 获取package.json版本号
|
|
id: version
|
|
run: |
|
|
VERSION=$(grep -m1 '"version":' package.json | cut -d'"' -f4)
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Version from package.json: $VERSION"
|
|
|
|
- name: 登录到Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: 设置Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: 构建并推送Docker镜像
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max |