45 lines
1.9 KiB
YAML
45 lines
1.9 KiB
YAML
name: action-cd
|
||
description: "action repo 的共用 CD:checkout(PR 來源最新提交)→ next-version 算下一版 → 沒有跳過就打標籤並推送。只動文件、圖示、測試、.gitea/、go.mod 時跳過。內部用的版本取自呼叫端的 Gitea 變數:ACTION_CHECKOUT_VERSION、ACTION_NEXT_VERSION_VERSION"
|
||
inputs:
|
||
token:
|
||
description: "推送標籤用的權杖(需要 write:repository);空=用內建 github.token"
|
||
default: ""
|
||
docs_pattern:
|
||
description: "只動這些檔案就不發版的 egrep 規則"
|
||
default: '^\.gitea/|^icon\.|^test/|^go\.mod$|\.md$'
|
||
outputs:
|
||
version:
|
||
description: "這次發的版本(跳過時是下一版的預覽,沒有實際推送)"
|
||
value: ${{ steps.ver.outputs.version }}
|
||
skip:
|
||
description: "true=只動文件等檔案,沒有發版"
|
||
value: ${{ steps.ver.outputs.skip }}
|
||
runs:
|
||
using: composite
|
||
steps:
|
||
- uses: actions/checkout@${{ vars.ACTION_CHECKOUT_VERSION }}
|
||
with:
|
||
fetch-depth: 0
|
||
ref: ${{ github.event.pull_request.head.sha }}
|
||
token: ${{ inputs.token || github.token }}
|
||
- id: ver
|
||
uses: https://gitea.jsc.idv.tw/actions/next-version@${{ vars.ACTION_NEXT_VERSION_VERSION }}
|
||
with:
|
||
channel: release
|
||
docs_pattern: ${{ inputs.docs_pattern }}
|
||
- name: 只動文件等檔案,不發版
|
||
if: ${{ steps.ver.outputs.skip == 'true' }}
|
||
shell: bash
|
||
run: echo "不發版"
|
||
- name: 打標籤並推送
|
||
if: ${{ steps.ver.outputs.skip != 'true' }}
|
||
shell: bash
|
||
env:
|
||
VERSION: ${{ steps.ver.outputs.version }}
|
||
TOKEN: ${{ inputs.token || github.token }}
|
||
run: |
|
||
set -euo pipefail
|
||
git tag "$VERSION" HEAD
|
||
git push "${GITHUB_SERVER_URL%%://*}://oauth2:${TOKEN}@${GITHUB_SERVER_URL#*://}/${GITHUB_REPOSITORY}.git" "refs/tags/$VERSION"
|
||
echo "已推送標籤 $VERSION"
|