fix: harden daily workflow for manual runs
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user