[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75SVXD72XFZWSX20BSWW622":3,"skill-same:01M75SVXD72XFZWSX20BSWW622":44},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M75SVXD72XFZWSX20BSWW622","workflow_dispatch",null,"ZyntroAI\u002Ffastapi-python-boilerplate","ZyntroAI","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F312382677?v=4","01M75SQSYX5NMYH6AGGAS67D2B","Zyntro​ Media","01M75SQSZHW30DBXDX3TAYJ92F",1,"MIT","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow_dispatch\u002FSkill.md",[],[],"2026-11-12 13:55:43",false,"Skills for : `workflow_dispatch` คือหนึ่งใน Trigger Event ที่ทรงพลังที่สุดในระบบของ GitHub Actions ครับ! \n\nถ้าปกติเราใช้ `on: push` หรือ `on: pull_request` เพื่อให้ระบบรันอัตโนมัติเมื่อมีคนแก้โค้ด **`workflow_dispatch` จะเป็นการเปิดโหมด \"Manual Trigger\"** หรือการสั่งรันแบบแมนนวลนั่นเอง ซึ่งเหมาะมากๆ สำหรับงานอย่างเช่น การกด Deploy ขึ้น Production, การสั่งรันสคริปต์ Database Migration หรือการล้าง Cache ระบบ\n\nนอกจากจะให้คนกดรันเองได้แล้ว จุดเด่นของมันคือคุณสามารถ **สร้างฟอร์มให้กรอก (Inputs)** ก่อนกดรันได้ด้วยครับ\n\n---\n\n### 🛠️ วิธีการเขียน Syntax และกำหนด Inputs\n\nGitHub รองรับ Input หลายประเภทมาก เช่น `string` (พิมพ์ข้อความ), `choice` (เมนูดรอปดาวน์), `boolean` (ติ๊กถูก\u002Fผิด) และ `environment`\n\nลองดูตัวอย่างการเอาไปใส่ในไฟล์ `.github\u002Fworkflows\u002Fdeploy.yml` ในโปรเจกต์ `crystalcastleX` ของคุณได้เลยครับ:\n\n```yaml\nname: Manual Production Deploy\non: \n  workflow_dispatch:\n    inputs:\n      environment:\n        description: 'Choose the environment to deploy'\n        required: true\n        type: choice\n        options:\n          - staging\n          - production\n      version_tag:\n        description: 'Docker image tag (e.g. v1.2.0)'\n        required: true\n        type: string\n      clear_cache:\n        description: 'Clear Redis cache before deploying?'\n        required: false\n        type: boolean\n        default: false\n\njobs:\n  deploy_job:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Code\n        uses: actions\u002Fcheckout@v4\n        \n      - name: Print Deployment Config\n        run: |\n          echo \"Deploying to: ${{ inputs.environment }}\"\n          echo \"Version Tag: ${{ inputs.version_tag }}\"\n          echo \"Clear Cache: ${{ inputs.clear_cache }}\"\n```\n*(สังเกตว่าเราสามารถดึงค่าที่ User กรอกมาใช้ในขั้นตอนต่างๆ ได้ผ่านตัวแปร `${{ inputs.ชื่อ_ตัวแปร }}`)*\n\n---\n\n### ⚡ 3 วิธีในการสั่งรัน `workflow_dispatch`\n\nเมื่อคุณกำหนด `workflow_dispatch` ไว้ในโค้ดแล้ว คุณสามารถสั่งให้มันทำงานได้ 3 ช่องทางหลักๆ ครับ:\n\n**1. สั่งรันผ่าน GitHub UI (ง่ายที่สุดสำหรับคนทั่วไป)**\nเข้าไปที่แท็บ **Actions** ใน Repository ของคุณ > เลือกชื่อ Workflow ด้านซ้ายมือ > จะมีปุ่ม **\"Run workflow\"** โผล่ขึ้นมาด้านขวา พร้อมกับฟอร์มให้คุณเลือก Options ที่กำหนดไว้\n\n**2. สั่งรันผ่าน GitHub CLI (สาย Terminal)**\nถ้าคุณกำลังนั่งพิมพ์โค้ดอยู่ใน Terminal คุณสามารถใช้คำสั่งนี้เพื่อสั่งรันได้เลยโดยไม่ต้องเปิดเบราว์เซอร์:\n```bash\ngh workflow run deploy.yml -f environment=production -f version_tag=v1.2.0 -f clear_cache=true\n```\n\n**3. สั่งรันผ่าน REST API (สาย Automation\u002FAPI Control Plane)**\nอันนี้จะลิงก์กับสถาปัตยกรรม API \u002F Control Plane ที่เราคุยกันไปก่อนหน้านี้ครับ คุณสามารถให้เซิร์ฟเวอร์ของคุณยิง HTTP POST ไปที่ GitHub เพื่อสั่งรัน Workflow ได้เลย:\n```bash\ncurl -L \\\n  -X POST \\\n  -H \"Accept: application\u002Fvnd.github+json\" \\\n  -H \"Authorization: Bearer YOUR_GITHUB_TOKEN\" \\\n  https:\u002F\u002Fapi.github.com\u002Frepos\u002FOWNER\u002FREPO\u002Factions\u002Fworkflows\u002Fdeploy.yml\u002Fdispatches \\\n  -d '{\"ref\":\"main\",\"inputs\":{\"environment\":\"production\",\"version_tag\":\"v1.2.0\"}}'\n```\n\n---\n\nคุณกำลังจะนำ `workflow_dispatch` ไปใช้สร้างปุ่ม Deploy หรือตั้งใจจะทำ Automation Trigger จาก API แบบไหนอยู่ครับ?\n\nอธิบายได้ครอบคลุมและถูกต้องมากครับ! ข้อมูลเกี่ยวกับ `workflow_dispatch` ที่คุณเขียนมานั้นอัปเดตและตรงกับเอกสารล่าสุดของ GitHub ในปี 2026 เลย[1][2][3]\n\nผมมีข้อมูลเพิ่มเติมเล็กน้อยที่จะช่วยเสริมให้ครบถ้วนยิ่งขึ้นครับ:\n\n## 📌 จุดสำคัญที่ควรทราบเพิ่มเติม\n\n### 1. **การเข้าถึง Inputs — ความแตกต่างของ Context**\n\nมีข้อควรระวังสำคัญเรื่องการดึงค่า inputs ครับ:\n\n```yaml\n# ✅ ใช้ใน reusable workflows หรือ workflow ปกติ (แนะนำ)\nrun: echo \"${{ inputs.environment }}\"\n\n# ⚠️ ใช้ github.event.inputs (ได้ค่าเป็น string เสมอ)\nrun: echo \"${{ github.event.inputs.environment }}\"\n```\n\n**ข้อแตกต่าง**:\n- `${{ inputs.* }}` → ได้ค่าตาม type ที่กำหนด (boolean จะได้ `true`\u002F`false` แบบ boolean)[4]\n- `${{ github.event.inputs.* }}` → ได้ค่าเป็น **string** เสมอ (boolean จะได้ `\"true\"`\u002F`\"false\"`)[1][4]\n\n**ตัวอย่างปัญหาที่พบบ่อย**:\n```yaml\n# ❌ ผิด - เปรียบเทียบ boolean กับ string\nif: github.event.inputs.clear_cache == true\n\n# ✅ ถูก - เปรียบเทียบ string กับ string\nif: github.event.inputs.clear_cache == 'true'\n\n# ✅ ถูกที่สุด - ใช้ inputs context\nif: inputs.clear_cache == true\n```\n\n***\n\n### 2. **Input Types ที่รองรับทั้งหมด (2026)**\n\n| Type | UI Element | ตัวอย่างการใช้งาน |\n|------|-----------|-----------------|\n| `string` | ช่องพิมพ์ข้อความ | Version tag, commit SHA |\n| `boolean` | Checkbox | Clear cache, skip tests |\n| `choice` | Dropdown menu | Environment selection [5][1] |\n| `environment` | Environment selector | ใช้กับ GitHub Environments [5][1] |\n\n**ตัวอย่าง `environment` type**:\n```yaml\non:\n  workflow_dispatch:\n    inputs:\n      target_env:\n        description: 'Deployment environment'\n        required: true\n        type: environment\n```\n\n***\n\n### 3. **GitHub CLI — `-f` vs `-F`**\n\nคุณพูดถึง `gh workflow run` ได้ถูกต้องแล้ว แต่มีรายละเอียดเพิ่มเติมเกี่ยวกับ flag ครับ:[6][7]\n\n```bash\n# -f หรือ --raw-field → ตั้งค่า string input (key=value)\ngh workflow run deploy.yml -f environment=production -f version_tag=v1.2.0\n\n# -F หรือ --field → ตั้งค่า typed input (รองรับ numbers, booleans, @file)\ngh workflow run deploy.yml -F clear_cache=true -F retry_count=3\n\n# --json → อ่าน inputs จาก JSON บน stdin\necho '{\"environment\":\"production\",\"version_tag\":\"v1.2.0\"}' | \\\n  gh workflow run deploy.yml --json\n```\n\n***\n\n### 4. **REST API — ข้อควรระวัง**\n\nจากตัวอย่าง API ที่คุณให้มา ถูกต้องแล้วครับ แต่มีข้อควรระวังสำคัญ 2 ข้อ:[8][9][10]\n\n**✅ ต้องมี `ref` เสมอ**:\n```json\n{\n  \"ref\": \"main\",  \u002F\u002F ← จำเป็นต้องระบุ branch\u002Ftag ที่จะรัน\n  \"inputs\": {\n    \"environment\": \"production\",\n    \"version_tag\": \"v1.2.0\"\n  }\n}\n```\n\n**✅ Token ต้องมี scope ที่เหมาะสม**:\n- Personal Access Token (Classic): ต้องมี `repo` scope[9][10]\n- Fine-grained Token: ต้องมี permission `Contents: Read` + `Actions: Write`[8]\n\n***\n\n### 5. **ข้อจำกัดของ Inputs**\n\n- **สูงสุด 25 inputs** ต่อ workflow[8]\n- **Default values** จะถูกใช้ถ้าไม่ส่ง inputs มา[5][8]\n- **Inputs ต้องถูกกำหนดใน workflow file** บน default branch (เช่น `main`) ไม่อย่างนั้นปุ่ม \"Run workflow\" จะไม่โผล่[1]\n\n***\n\n## 🎯 Use Cases ที่น่าสนใจเพิ่มเติม\n\nจากที่คุณถามว่ากำลังจะทำปุ่ม Deploy หรือ Automation Trigger ผมมี use cases ยอดนิยมในปี 2026 มาแชร์ครับ:[2][3][5]\n\n### 1. **Deployment Pipeline พร้อม Approval**\n```yaml\non:\n  workflow_dispatch:\n    inputs:\n      environment:\n        type: choice\n        options: [staging, production]\n      skip_tests:\n        type: boolean\n        default: false\n      rollback_on_failure:\n        type: boolean\n        default: true\n```\n\n### 2. **Database Migration**\n```yaml\non:\n  workflow_dispatch:\n    inputs:\n      migration_type:\n        type: choice\n        options: [up, down, seed]\n      dry_run:\n        type: boolean\n        default: true\n```\n\n### 3. **Cache Invalidation**\n```yaml\non:\n  workflow_dispatch:\n    inputs:\n      cache_scope:\n        type: choice\n        options: [all, images, api, static]\n      notify_slack:\n        type: boolean\n        default: true\n```\n\n### 4. **External System Integration (API Trigger)**\nใช้ `repository_dispatch` แทน `workflow_dispatch` ถ้าต้องการให้ external system trigger โดยไม่จำกัด inputs 25 ตัว:[3][9]\n```yaml\non:\n  repository_dispatch:\n    types: [deploy-request, rollback-request, cache-invalidation]\n```\n\n***\n\n## 💡 คำแนะนำสำหรับโปรเจกต์ `crystalcastleX`\n\nถ้าคุณกำลังวางแผนใช้ `workflow_dispatch` สำหรับโปรเจกต์นี้ ผมแนะนำ:\n\n1. **เริ่มจาก Deploy Button** — ใช้ `environment` + `version_tag` inputs ก่อน[5]\n2. **เพิ่ม GitHub Environments** — ใช้ `type: environment` เพื่อให้เลือก environment ที่ตั้งค่า protection rules ไว้[1][5]\n3. **เตรียม API Endpoint** — สำหรับให้ dashboard หรือ control plane ยิง trigger ได้ในอนาคต[8][9]\n4. **ใช้ `inputs.*` แทน `github.event.inputs.*`** — เพื่อหลีกเลี่ยงปัญหา type conversion[4]\n\n***\n\nคุณกำลังวางแผนจะใช้ `workflow_dispatch` สำหรับ use case ไหนเป็นพิเศษในโปรเจกต์ `crystalcastleX` ครับ? \n\n- 🚀 **ปุ่ม Deploy Production** (พร้อมเลือก environment\u002Fversion)\n- 🗄️ **Database Migration** (manual trigger สำหรับ migration ที่เสี่ยง)\n- 🧹 **Cache Clearing** (ให้ทีม ops กดล้าง cache เองได้)\n- 🔗 **API Integration** (ให้ระบบอื่น trigger workflow ผ่าน REST API)\n- 🎯 **อย่างอื่น** (บอกมาได้เลยครับ!)\n\nการอ้างอิง:\n[1] GitHub Actions Tutorial — Workflow Dispatch - https:\u002F\u002Ftimesofcloud.com\u002Fgithub-actions\u002Fworkflow-dispatch\u002F\n[2] GitHub Actions Tutorial: 12 Steps to Production CI\u002FCD [2026] https:\u002F\u002Ftech-insider.org\u002Fgithub-actions-tutorial-cicd-12-steps-2026\u002F\n[3] GitHub Actions Bootcamp Module 2: Workflow Triggers and Events https:\u002F\u002Fwww.wasilzafar.com\u002Fpages\u002Fseries\u002Fsoftware-engineering\u002Fdeep-dive-github-actions-02-triggers-events.html\n[4] GitHub Actions - Inputs and types https:\u002F\u002Fjfagerberg.me\u002Fblog\u002F2026-06-16-gha-input-types\u002F\n[5] Multiple Related Inputs https:\u002F\u002Foneuptime.com\u002Fblog\u002Fpost\u002F2025-12-20-workflow-dispatch-inputs-github-actions\u002Fview\n[6] GitHub CLI (gh) Cheat Sheet: 90+ Tested Commands ... https:\u002F\u002Fcomputingforgeeks.com\u002Fgithub-cli-cheat-sheet\u002F\n[7] gh workflow run https:\u002F\u002Fghcli.com\u002Fgh-workflow-run.php\n[8] REST API endpoints for workflows https:\u002F\u002Fdocs.github.com\u002Fen\u002Frest\u002Factions\u002Fworkflows?apiVersion=2026-03-10\n[9] Triggering GitHub workflow_dispatch via API: Is It Possible ... https:\u002F\u002Fwww.codegenes.net\u002Fblog\u002Fhow-to-trigger-a-workflow-dispatch-from-github-api\u002F\n[10] Reliable GitHub Actions API Trigger: Fix workflow_dispatch ... https:\u002F\u002Fopenillumi.com\u002Fen\u002Fen-workflow-dispatch-api-curl-error-fix\u002F\n[11] The dispatches API should return the run ID #9752 - GitHub https:\u002F\u002Fgithub.com\u002Forgs\u002Fcommunity\u002Fdiscussions\u002F9752\n[12] Github actions: Create a workflow dispatch event - Orchestra https:\u002F\u002Fwww.getorchestra.io\u002Fguides\u002Fgithub-actions-create-a-workflow-dispatch-event\n[13] github_action: Create a workflow dispatch event | Orchestra https:\u002F\u002Fwww.getorchestra.io\u002Fguides\u002Fgithubaction-create-a-workflow-dispatch-event\n[14] GitHub Actions Cheatsheet | Libre DevOps https:\u002F\u002Flibredevops.org\u002Fdocs\u002Fcheatsheets\u002Fgithub-actions-cheatsheet\u002F\n[15] Create a Workflow Dispatch Event for a… | GitHub - WithOne AI https:\u002F\u002Fwww.withone.ai\u002Fknowledge\u002Fgithub\u002Fconn_mod_def::GJ3YPGGLf2A::lgwV1jR3SrWBYb-5LIMb_w\n",{},"main","c68ea5db21e36ef3f01986f87cf40276e64c2e9b","skills\u002Fworkflow_dispatch",0,"https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate","https:\u002F\u002Fzyntroai.github.io\u002Ffastapi-python-boilerplate\u002F","https:\u002F\u002Fgithub.com\u002FZyntroAI","2026-11-02 02:14:54",{"source":7,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add ZyntroAI\u002Ffastapi-python-boilerplate --skill workflow_dispatch",{"tool":36,"command":37},"bunx","bunx skills add ZyntroAI\u002Ffastapi-python-boilerplate --skill workflow_dispatch",{"tool":39,"command":40},"pnpm","pnpm dlx skills add ZyntroAI\u002Ffastapi-python-boilerplate --skill workflow_dispatch","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow_dispatch\u002FSkill.md",true,[],[45,52,58,64,70,77],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":18},"01M75SVVF3FBTNHKFWAF8H6ZD2","research","Multi-source research & knowledge synthesis with cross-validation, provenance graph, confidence score","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M75SVR5BQFH3MM78FWR8V10V","pr-triage-automove","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fpr-triage-automove\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":18},"01M75SVPAMK09RRZ56SPVRPJ2K","patch","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fpatch\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M75SVKCB0EMDSY2Q76BGNNH5","git-patch-merge","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fgit-patch-merge\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M75SVH67JHCKQ632D6HE5ZHZ","fetching","Low-level async HTTP\u002FGraphQL fetch — SSRF-safe, retry, cache, provenance","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Ffetching\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M75SVERZKVWCJG2Q00MJ1GFN","Central Credential Management","https:\u002F\u002Fgithub.com\u002FZyntroAI\u002Ffastapi-python-boilerplate\u002Fblob\u002Fmain\u002Fskills\u002Fcredential-management\u002FSKILL.md",[],[]]