注释掉 Docker 构建和发布工作流中的 push 事件,改为手动触发

This commit is contained in:
hi2hi 2024-12-05 09:28:56 +00:00
parent 56d8706d29
commit 7cf1c7ddf2
2 changed files with 32 additions and 16 deletions

View File

@ -1,10 +1,11 @@
name: Build and Push Docker Image
on:
push:
branches:
- main # 监听 main 分支的 push 操作
workflow_dispatch: # 手动触发
workflow_dispatch:
inputs:
version:
description: 'Version to use for the Docker image'
required: false
jobs:
build:
@ -22,9 +23,14 @@ jobs:
- name: Install dependencies
run: npm install
- name: Get version from package.json
id: get_version
run: echo "VERSION=$(node -p 'require("./package.json").version')" >> $GITHUB_ENV
- name: Determine version
id: determine_version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "VERSION=$(node -p 'require("./package.json").version')" >> $GITHUB_ENV
else
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
fi
- name: Print version
run: echo "Version is $VERSION"

View File

@ -1,10 +1,11 @@
name: Build and Release
on:
push:
branches:
- main # 监听 main 分支的 push 操作
workflow_dispatch: # 手动触发支持
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: false
jobs:
build-and-release:
@ -29,20 +30,29 @@ jobs:
id: get_version
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
- name: Determine version
id: determine_version
run: |
if [ "${{ github.event.inputs.version }}" ]; then
echo "::set-output name=version::${{ github.event.inputs.version }}"
else
echo "::set-output name=version::${{ steps.get_version.outputs.version }}"
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
tag_name: v${{ steps.determine_version.outputs.version }}
release_name: Release v${{ steps.determine_version.outputs.version }}
draft: false
prerelease: false
- name: Package build output
run: |
zip -r build-v${{ steps.get_version.outputs.version }}.zip dist
zip -r build-v${{ steps.determine_version.outputs.version }}.zip dist
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
@ -50,6 +60,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build-v${{ steps.get_version.outputs.version }}.zip
asset_name: build-v${{ steps.get_version.outputs.version }}.zip
asset_path: ./build-v${{ steps.determine_version.outputs.version }}.zip
asset_name: build-v${{ steps.determine_version.outputs.version }}.zip
asset_content_type: application/zip