| | @@ -10,7 +10,7 @@ |
| 10 | 10 | # are mirrored. |
| 11 | 11 | # |
| 12 | 12 | # Reads Diffinery with DIFFINERY_TOKEN when set (not needed once the repo is public); |
| 13 | | -# MIRROR_SRC can also be a local clone that has main. Pushes with GITHUB_MIRROR_TOKEN |
| 13 | +# MIRROR_SRC can also be a local clone that has main. Pushes with MIRROR_TOKEN |
| 14 | 14 | # when set, otherwise with whatever credentials git already has for github.com. |
| 15 | 15 | # Needs git-filter-repo 2.47.0 (pip install git-filter-repo==2.47.0); another |
| 16 | 16 | # version could write different commits. |
| | @@ -37,8 +37,8 @@ |
| 37 | 37 | # The helper reads the token from the environment, so it never lands on a command line. |
| 38 | 38 | auth=(-c 'credential.https://diffinery.com.helper=!f() { [ "$1" = get ] && printf "username=x-token\npassword=%s\n" "$DIFFINERY_TOKEN"; }; f') |
| 39 | 39 | fi |
| 40 | | -if [ -n "${GITHUB_MIRROR_TOKEN:-}" ]; then |
| 41 | | - auth+=(-c 'credential.https://github.com.helper=!f() { [ "$1" = get ] && printf "username=x-access-token\npassword=%s\n" "$GITHUB_MIRROR_TOKEN"; }; f') |
| 40 | +if [ -n "${MIRROR_TOKEN:-}" ]; then |
| 41 | + auth+=(-c 'credential.https://github.com.helper=!f() { [ "$1" = get ] && printf "username=x-access-token\npassword=%s\n" "$MIRROR_TOKEN"; }; f') |
| 42 | 42 | fi |
| 43 | 43 | git "${auth[@]}" clone --quiet --bare --single-branch --branch main "$SRC" "$work/repo.git" |
| 44 | 44 | cd "$work/repo.git" |
| | @@ -84,8 +84,8 @@ |
| 84 | 84 | done |
| 85 | 85 | |
| 86 | 86 | # Releases on the mirrored tags get the same name, notes and flags on GitHub (assets aren't copied). |
| 87 | | -# Needs GITHUB_MIRROR_TOKEN for GitHub's API. |
| 88 | | -if [ -n "${GITHUB_MIRROR_TOKEN:-}" ] && [ ${#mirrored[@]} -gt 0 ]; then |
| 87 | +# Needs MIRROR_TOKEN for GitHub's API. |
| 88 | +if [ -n "${MIRROR_TOKEN:-}" ] && [ ${#mirrored[@]} -gt 0 ]; then |
| 89 | 89 | MIRROR_TAGS="${mirrored[*]}" python3 - <<'PY' |
| 90 | 90 | import json, os, urllib.error, urllib.request |
| 91 | 91 | |
| | @@ -107,7 +107,7 @@ |
| 107 | 107 | except urllib.error.HTTPError as e: |
| 108 | 108 | return e.code, None |
| 109 | 109 | |
| 110 | | -token = os.environ["GITHUB_MIRROR_TOKEN"] |
| 110 | +token = os.environ["MIRROR_TOKEN"] |
| 111 | 111 | status, me = call("GET", f"{dst.split('/repos/')[0]}/user", token=token) |
| 112 | 112 | me = me.get("login") if status == 200 else None |
| 113 | 113 | status, releases = call("GET", f"{src}/releases?per_page=100", token=os.environ.get("DIFFINERY_TOKEN")) |