fix: restore working github forgejo sync
This commit is contained in:
parent
ef9fed75cb
commit
d124a91dea
1 changed files with 13 additions and 18 deletions
31
.github/workflows/sync-to-forgejo.yml
vendored
31
.github/workflows/sync-to-forgejo.yml
vendored
|
|
@ -10,14 +10,14 @@ jobs:
|
||||||
sync:
|
sync:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Push branch to Forgejo
|
- name: Sync to Forgejo
|
||||||
env:
|
env:
|
||||||
FORGEJO_SECRET: ${{ secrets.FORGEJO_SECRET || secrets.GITEA_SECRET }}
|
FORGEJO_SECRET: ${{ secrets.FORGEJO_SECRET || secrets.GITEA_SECRET }}
|
||||||
FORGEJO_OWNER: ${{ secrets.FORGEJO_OWNER || 'ashwin' }}
|
FORGEJO_OWNER: ${{ secrets.FORGEJO_OWNER || 'ashwin' }}
|
||||||
|
|
@ -25,21 +25,16 @@ jobs:
|
||||||
REPO: ${{ github.event.repository.name }}
|
REPO: ${{ github.event.repository.name }}
|
||||||
BRANCH: ${{ github.ref_name }}
|
BRANCH: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euxo pipefail
|
||||||
test -n "${FORGEJO_SECRET:-}" || { echo "FORGEJO_SECRET is empty"; exit 1; }
|
export GIT_TERMINAL_PROMPT=0
|
||||||
|
export GIT_TRACE=1
|
||||||
|
export GIT_CURL_VERBOSE=1
|
||||||
|
|
||||||
ENCODED_PASSWORD="$(python3 - <<'PY'
|
USER="${FORGEJO_USERNAME}"
|
||||||
import os
|
AUTH="$(printf '%s' "${USER}:${FORGEJO_SECRET}" | base64 -w0)"
|
||||||
import urllib.parse
|
|
||||||
print(urllib.parse.quote(os.environ['FORGEJO_SECRET'], safe=''))
|
|
||||||
PY
|
|
||||||
)"
|
|
||||||
TARGET="https://${FORGEJO_USERNAME}:${ENCODED_PASSWORD}@ci.nxtgauge.com/${FORGEJO_OWNER}/${REPO}.git"
|
|
||||||
|
|
||||||
git config user.name "github-actions[bot]"
|
test -n "${FORGEJO_SECRET:-}" || (echo "FORGEJO_SECRET empty" && exit 1)
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
curl -fsS -H "Authorization: Basic ${AUTH}" https://ci.nxtgauge.com/api/v1/user >/dev/null
|
||||||
git remote remove forgejo 2>/dev/null || true
|
curl -fsS -X POST \
|
||||||
git remote add forgejo "${TARGET}"
|
-H "Authorization: Basic ${AUTH}" \
|
||||||
|
"https://ci.nxtgauge.com/api/v1/repos/${FORGEJO_OWNER}/${REPO}/mirror-sync" >/dev/null
|
||||||
git push forgejo "HEAD:${BRANCH}" --force
|
|
||||||
git push forgejo --tags --force
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue