fix: harden daily workflow for manual runs
This commit is contained in:
@@ -33,8 +33,9 @@ jobs:
|
|||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${GITEA_TOKEN}" ]; then
|
if [ -z "${GITEA_TOKEN}" ]; then
|
||||||
echo "Missing secret GITEA_TOKEN" >&2
|
echo "Warning: missing GITEA_TOKEN, release publish step will fail."
|
||||||
exit 1
|
else
|
||||||
|
echo "GITEA_TOKEN exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Prepare config
|
- name: Prepare config
|
||||||
@@ -69,27 +70,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Commit and push builder updates
|
- name: Commit and push builder updates
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
|
||||||
GITEA_BASE_URL: ${{ vars.GITEA_BASE_URL }}
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
base="${GITEA_BASE_URL:-https://git.halonice.com}"
|
branch="${GITHUB_REF_NAME:-}"
|
||||||
base="${base%/}"
|
if [ -z "${branch}" ]; then
|
||||||
branch="${GITHUB_REF_NAME:-main}"
|
branch="$(git rev-parse --abbrev-ref HEAD || true)"
|
||||||
repo_path="${GITHUB_REPOSITORY}"
|
|
||||||
if [ -z "${repo_path}" ]; then
|
|
||||||
echo "GITHUB_REPOSITORY is empty" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
if [ -z "${branch}" ] || [ "${branch}" = "HEAD" ]; then
|
||||||
if [[ "${base}" == https://* ]]; then
|
branch="main"
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git config user.name "gitea-actions[bot]"
|
git config user.name "gitea-actions[bot]"
|
||||||
@@ -100,7 +88,6 @@ jobs:
|
|||||||
echo "builder_changed=false" >> "$GITHUB_ENV"
|
echo "builder_changed=false" >> "$GITHUB_ENV"
|
||||||
else
|
else
|
||||||
git commit -m "chore: daily sync and generate rules"
|
git commit -m "chore: daily sync and generate rules"
|
||||||
git remote set-url origin "${authed_repo_url}"
|
|
||||||
git push origin "HEAD:${branch}"
|
git push origin "HEAD:${branch}"
|
||||||
echo "builder_changed=true" >> "$GITHUB_ENV"
|
echo "builder_changed=true" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
@@ -115,6 +102,10 @@ jobs:
|
|||||||
TARGET_BRANCH: ${{ vars.TARGET_BRANCH }}
|
TARGET_BRANCH: ${{ vars.TARGET_BRANCH }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
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="${GITEA_BASE_URL:-https://git.halonice.com}"
|
||||||
base="${base%/}"
|
base="${base%/}"
|
||||||
owner="${TARGET_OWNER:-yuanzhen869}"
|
owner="${TARGET_OWNER:-yuanzhen869}"
|
||||||
|
|||||||
Reference in New Issue
Block a user