From 870684bf7d7acb3d2d7d889311b7f594474faeb3 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Thu, 11 Jun 2026 18:00:03 +0530 Subject: [PATCH] fix: add github to forgejo sync workflow --- .github/workflows/sync-to-forgejo.yml | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/sync-to-forgejo.yml diff --git a/.github/workflows/sync-to-forgejo.yml b/.github/workflows/sync-to-forgejo.yml new file mode 100644 index 0000000..b16b2a4 --- /dev/null +++ b/.github/workflows/sync-to-forgejo.yml @@ -0,0 +1,47 @@ +name: sync-to-forgejo + +on: + push: + branches: + - main + +jobs: + sync: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Sync to Forgejo + env: + FORGEJO_TOKEN: ${{ secrets.FORGEJO_SECRET }} + FORGEJO_OWNER: ${{ secrets.FORGEJO_OWNER || 'ashwin' }} + REPO: ${{ github.event.repository.name }} + BRANCH: ${{ github.ref_name }} + run: | + set -euxo pipefail + export GIT_TERMINAL_PROMPT=0 + export GIT_TRACE=1 + export GIT_CURL_VERBOSE=1 + + USER="${FORGEJO_OWNER}" + TARGET="https://ci.nxtgauge.com/${FORGEJO_OWNER}/${REPO}.git" + AUTH="$(printf '%s' "${USER}:${FORGEJO_TOKEN}" | base64 -w0)" + + test -n "${FORGEJO_TOKEN:-}" || (echo "FORGEJO_TOKEN empty" && exit 1) + curl -fsS -H "Authorization: token ${FORGEJO_TOKEN}" https://ci.nxtgauge.com/api/v1/user >/dev/null + curl -fsS -H "Authorization: Basic ${AUTH}" "${TARGET}/info/refs?service=git-receive-pack" >/dev/null + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git config --global http.version HTTP/1.1 + git config --global http.postBuffer 524288000 + git remote remove forgejo 2>/dev/null || true + git remote add forgejo "${TARGET}" + + git -c http.extraheader="Authorization: Basic ${AUTH}" push forgejo "HEAD:${BRANCH}" --force + git -c http.extraheader="Authorization: Basic ${AUTH}" push forgejo --tags --force