+55
@@ -0,0 +1,55 @@
|
||||
name: deploy
|
||||
description: "把 Go 應用程式的指定版本部署到這台主機(composite action,三個步驟:檢查環境 → go install 指定版本 → 安裝與啟動服務,失敗換回上一版)。要在目標主機的 runner 上執行,且主機要有 git 才能 uses;沒有 git 的主機改用 curl 抓本 repo 的 run.sh 再執行(見 README)。版本一定要明確傳入,不會拿 @latest"
|
||||
inputs:
|
||||
version:
|
||||
description: "要部署的確切版本,例如 v0.4.9 或 v0.5.0-dev.2"
|
||||
required: true
|
||||
token:
|
||||
description: "套件庫需要驗證時的權杖(需要 read:package)"
|
||||
default: ""
|
||||
go_version:
|
||||
description: "需要的 Go 版本(通常是 vars.GO_VERSION);主機的 Go 不足就下載安裝"
|
||||
required: true
|
||||
addr:
|
||||
description: "服務不存在、要安裝時的監聽位址(通常是 vars.DEPLOY_ADDR;空=預設 0.0.0.0:8080)"
|
||||
default: ""
|
||||
data:
|
||||
description: "服務不存在、要安裝時的資料目錄(通常是 vars.DEPLOY_DATA;空=預設 /var/lib/<名稱>)"
|
||||
default: ""
|
||||
name:
|
||||
description: "應用程式名稱,決定執行檔(/usr/local/bin/<名稱>)、服務名稱、go install 的 cmd/<名稱> 與資料目錄;預設是儲存庫名稱"
|
||||
default: ""
|
||||
gitea_url:
|
||||
description: "Gitea 網址,預設是目前的 Gitea(github.server_url)"
|
||||
default: ${{ github.server_url }}
|
||||
gitea_repo:
|
||||
description: "Gitea 儲存庫 <擁有者>/<名稱>,預設是目前的儲存庫(github.repository)"
|
||||
default: ${{ github.repository }}
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: 1. 檢查環境
|
||||
shell: bash
|
||||
env:
|
||||
DEPLOY_NAME: ${{ inputs.name }}
|
||||
GITEA_URL: ${{ inputs.gitea_url }}
|
||||
GITEA_REPO: ${{ inputs.gitea_repo }}
|
||||
GO_VERSION: ${{ inputs.go_version }}
|
||||
run: bash "${{ github.action_path }}/check-env.sh"
|
||||
- name: 2. go install 指定版本
|
||||
shell: bash
|
||||
env:
|
||||
DEPLOY_NAME: ${{ inputs.name }}
|
||||
GITEA_TOKEN: ${{ inputs.token }}
|
||||
GITEA_URL: ${{ inputs.gitea_url }}
|
||||
GITEA_REPO: ${{ inputs.gitea_repo }}
|
||||
run: bash "${{ github.action_path }}/install-binary.sh" "${{ inputs.version }}"
|
||||
- name: 3. 安裝與啟動服務
|
||||
shell: bash
|
||||
env:
|
||||
DEPLOY_NAME: ${{ inputs.name }}
|
||||
GITEA_URL: ${{ inputs.gitea_url }}
|
||||
GITEA_REPO: ${{ inputs.gitea_repo }}
|
||||
DEPLOY_ADDR: ${{ inputs.addr }}
|
||||
DEPLOY_DATA: ${{ inputs.data }}
|
||||
run: bash "${{ github.action_path }}/activate.sh" "${{ inputs.version }}"
|
||||
Reference in New Issue
Block a user