CD: uat.yml แก้ Run workflow จาก UI ไม่ได้บน Forgejo 11 — อาการ: กด Run workflow แล้วไม่มีช่องกรอก version แต่ backend ขวางด้วย "Require value for input" (Forgejo 11 base Gitea 1.22 = UI ยังไม่ render workflow_dispatch input fields, Gitea เพิ่มใน 1.23-1.24) — แก้ 2 ชั้น: (1) input เติม type: string ตาม GitHub spec เผื่อ renderer ต้องเจอ type ถึงวาดช่อง (2) required: false + step Resolve รองรับค่าว่าง: dispatch โดยไม่ใส่ version = deploy :latest (image ล่าสุดที่ build.yml push ตอน tag v* — คือเวอร์ชันที่เพิ่ง deploy Test ไป) ใส่ค่ามา (1.2.3/v1.2.3/deploy1.2.3) ก็ map เป็น v1.2.3 เหมือนเดิม + เขียน if/else แยก event แทน &&/|| เพราะ input ว่างจะ short-circuit ตกไปใช้ ref_name (ชื่อ branch) เกิดเป็น image vdev — verify: js-yaml ผ่าน + ทดสอบ resolve ครบ (deploy1.2.3/v1.2.3/1.2.3 → v1.2.3, ว่าง → latest)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
e0c78d68fe
commit
025ca2ce48
1 changed files with 15 additions and 7 deletions
|
|
@ -7,8 +7,9 @@ on:
|
|||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "เวอร์ชันที่จะ deploy เช่น 1.2.3 / v1.2.3 / deploy1.2.3 — จะ map เป็น image v1.2.3 (ต้อง push tag v1.2.3 ให้ build.yml build ไว้ก่อน)"
|
||||
required: true
|
||||
description: "เวอร์ชันที่จะ deploy เช่น 1.2.3 / v1.2.3 / deploy1.2.3 — จะ map เป็น image v1.2.3 | เว้นว่าง = latest (image ล่าสุดที่ build.yml push ไว้)"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
env:
|
||||
# Container Registry
|
||||
|
|
@ -102,13 +103,20 @@ jobs:
|
|||
outputs:
|
||||
image_tag: ${{ steps.image-tag.outputs.tag }}
|
||||
steps:
|
||||
- name: Resolve image tag (deploy1.2.3 / v1.2.3 → v1.2.3)
|
||||
- name: Resolve image tag (deploy1.2.3 / v1.2.3 → v1.2.3, ว่าง → latest)
|
||||
id: image-tag
|
||||
run: |
|
||||
RAW="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }}"
|
||||
TAG="${RAW#deploy}"
|
||||
TAG="${TAG#v}"
|
||||
TAG="v$TAG"
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
RAW="${{ github.event.inputs.version }}"
|
||||
else
|
||||
RAW="${{ github.ref_name }}"
|
||||
fi
|
||||
TAG="latest"
|
||||
if [ -n "$RAW" ]; then
|
||||
TAG="${RAW#deploy}"
|
||||
TAG="${TAG#v}"
|
||||
TAG="v$TAG"
|
||||
fi
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
echo "Reuse image จาก build.yml: ${{ env.REGISTRY_URL }}/${{ env.WEB_IMAGE_NAME }}:$TAG"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue