diff --git a/.forgejo/workflows/uat.yml b/.forgejo/workflows/uat.yml index e38514c..a648843 100644 --- a/.forgejo/workflows/uat.yml +++ b/.forgejo/workflows/uat.yml @@ -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"