diff --git a/.gitea/workflows/diagnose.yaml b/.gitea/workflows/diagnose.yaml index 994f1cb..32f3d42 100644 --- a/.gitea/workflows/diagnose.yaml +++ b/.gitea/workflows/diagnose.yaml @@ -1,5 +1,5 @@ -name: Diagnose GitHub mirror +name: Diagnose GitHub sync on: push: @@ -11,16 +11,24 @@ jobs: diagnose: runs-on: ubuntu-latest steps: - - name: Check source and credentials + - name: Check GitHub access env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | set -eu - echo "Triggered ref: $GITHUB_REF" - echo "Source commit: $GITHUB_SHA" - if [ -z "$GH_TOKEN" ]; then - echo "ERROR: GH_TOKEN is empty or unavailable" - exit 1 - fi - echo "GitHub token is present" - git --version + + REPO="tafakkur/PyNix-Website" + AUTH="$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\n')" + + git_auth() { + git -c http.extraheader="AUTHORIZATION: basic $AUTH" "$@" + } + + echo "Checking GitHub repository access..." + git_auth ls-remote \ + "https://github.com/${REPO}.git" refs/heads/main + + echo "Checking source commit..." + echo "$GITHUB_SHA" + + echo "GitHub read access succeeded."