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_SECRET: ${{ secrets.FORGEJO_SECRET || secrets.GITEA_SECRET }} FORGEJO_OWNER: ${{ secrets.FORGEJO_OWNER || 'ashwin' }} FORGEJO_USERNAME: ${{ secrets.FORGEJO_USERNAME || secrets.GITEA_USERNAME || '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_USERNAME}" TARGET="https://ci.nxtgauge.com/${FORGEJO_OWNER}/${REPO}.git" AUTH="$(printf '%s' "${USER}:${FORGEJO_SECRET}" | base64 -w0)" test -n "${FORGEJO_SECRET:-}" || (echo "FORGEJO_SECRET empty" && exit 1) curl -fsS -H "Authorization: Basic ${AUTH}" 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