From 891af1b740b191006455907365c68f6f72f4c58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E9=9C=87?= Date: Mon, 6 Apr 2026 14:22:32 +0800 Subject: [PATCH] fix: harden daily workflow for manual runs --- .gitea/workflows/repo-manage-daily.yml | 33 ++++++++++---------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/repo-manage-daily.yml b/.gitea/workflows/repo-manage-daily.yml index f811b40d4..d3b260f2a 100644 --- a/.gitea/workflows/repo-manage-daily.yml +++ b/.gitea/workflows/repo-manage-daily.yml @@ -33,8 +33,9 @@ jobs: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | if [ -z "${GITEA_TOKEN}" ]; then - echo "Missing secret GITEA_TOKEN" >&2 - exit 1 + echo "Warning: missing GITEA_TOKEN, release publish step will fail." + else + echo "GITEA_TOKEN exists." fi - name: Prepare config @@ -69,27 +70,14 @@ jobs: - name: Commit and push builder updates shell: bash - env: - GITEA_BASE_URL: ${{ vars.GITEA_BASE_URL }} - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | set -euo pipefail - base="${GITEA_BASE_URL:-https://git.halonice.com}" - base="${base%/}" - branch="${GITHUB_REF_NAME:-main}" - repo_path="${GITHUB_REPOSITORY}" - if [ -z "${repo_path}" ]; then - echo "GITHUB_REPOSITORY is empty" >&2 - exit 1 + branch="${GITHUB_REF_NAME:-}" + if [ -z "${branch}" ]; then + branch="$(git rev-parse --abbrev-ref HEAD || true)" fi - - if [[ "${base}" == https://* ]]; then - authed_repo_url="https://${GITEA_TOKEN}@${base#https://}/${repo_path}.git" - elif [[ "${base}" == http://* ]]; then - authed_repo_url="http://${GITEA_TOKEN}@${base#http://}/${repo_path}.git" - else - echo "GITEA_BASE_URL must start with http:// or https://" >&2 - exit 1 + if [ -z "${branch}" ] || [ "${branch}" = "HEAD" ]; then + branch="main" fi git config user.name "gitea-actions[bot]" @@ -100,7 +88,6 @@ jobs: echo "builder_changed=false" >> "$GITHUB_ENV" else git commit -m "chore: daily sync and generate rules" - git remote set-url origin "${authed_repo_url}" git push origin "HEAD:${branch}" echo "builder_changed=true" >> "$GITHUB_ENV" fi @@ -115,6 +102,10 @@ jobs: TARGET_BRANCH: ${{ vars.TARGET_BRANCH }} run: | set -euo pipefail + if [ -z "${GITEA_TOKEN}" ]; then + echo "Missing secret GITEA_TOKEN for release publish" >&2 + exit 1 + fi base="${GITEA_BASE_URL:-https://git.halonice.com}" base="${base%/}" owner="${TARGET_OWNER:-yuanzhen869}"