Files
brencher/.github/workflows/merge_main.yaml
T
hermes 75126cb2fd
Merge main to all / rebase (push) Failing after 28s
Python package / build (3.12.3) (push) Successful in 2m33s
Python package / build (3.13) (push) Successful in 2m20s
Python package / build (3.14) (push) Successful in 2m16s
ci(merge_main): hardcode gitea.rudolf.keenetic.link (GITEA_SERVER_URL empty) (#47)
## Problem

Run #67 of `merge_main.yaml` failed with:

```
fatal: unable to access 'https:///admin/brencher.git/': URL rejected: No host part in the URL
```

The `PUSH_TOKEN` secret is now wired up correctly, but `${GITEA_SERVER_URL}` is empty in this Gitea Actions runtime (the variable the env-prefixed runner is supposed to set), so the substituted URL drops the host.

## Fix

Hardcode `gitea.rudolf.keenetic.link` in both `merge_main.yaml` and `merge_main_and_squash.yaml`. When the runner exposes `GITEA_SERVER_URL` in a future version, this can be replaced back with `${GITEA_SERVER_URL#https://}`.

## Supersedes

This is a follow-up to admin/brencher#46 which already wired `secrets.PUSH_TOKEN` but still had the empty env var.Reviewed-on: http://192.168.1.96/admin/brencher/pulls/47

Co-authored-by: hermes <rudolfss13+hermes@gmail.com>
2026-09-04 16:26:09 +02:00

70 lines
1.9 KiB
YAML

name: Merge main to all
on:
push:
branches:
- main
concurrency:
group: rebase-on-main
cancel-in-progress: true
permissions:
contents: write
jobs:
rebase:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PUSH_TOKEN }}
- name: Configure git
run: |
git config user.email "gitea-actions[bot]@noreply.localhost"
git config user.name "Gitea Actions"
- name: Fetch all branches
run: |
git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@gitea.rudolf.keenetic.link/${GITHUB_REPOSITORY}.git"
git fetch --all --prune
- name: Merge every branch onto main
shell: bash
run: |
set -eo pipefail
MAIN=main
branches=$(git for-each-ref --format='%(refname:short)' refs/remotes/origin/ \
| sed 's|^origin/||' \
| grep -v -e '^HEAD$' -e '^main$' -e '^origin$' \
| sed '/^$/d' \
| sort -u || true)
failed=()
for br in $branches; do
if [[ "$br" == "$MAIN" ]]; then
continue
fi
echo "=== Processing branch: $br ==="
git checkout -B "$br" "origin/$br"
if git merge --no-edit "origin/$MAIN"; then
if git push origin "$br"; then
echo "Pushed merged $br"
else
echo "Push failed for $br"
failed+=("$br")
fi
else
echo "Merge failed for $br, aborting merge and skipping"
git merge --abort || true
failed+=("$br")
fi
done
if [ ${#failed[@]} -ne 0 ]; then
echo "Merge skipped/failed for branches: ${failed[*]}"
exit 1
else
echo "All branches merged successfully."
fi