diff --git a/.gitea/workflows/production-deploy.yml b/.gitea/workflows/production-deploy.yml index bc1389a0..1f3c6640 100644 --- a/.gitea/workflows/production-deploy.yml +++ b/.gitea/workflows/production-deploy.yml @@ -36,16 +36,21 @@ jobs: REF_NAME="main" fi - # Try HTTPS first, fallback to SSH - git clone --depth 1 --branch "$REF_NAME" \ - "https://git.michaelschiemer.de/${REPO}.git" \ - /workspace/repo || \ - git clone --depth 1 --branch "$REF_NAME" \ - "git@git.michaelschiemer.de:${REPO}.git" \ - /workspace/repo || \ - git clone --depth 1 \ - "https://git.michaelschiemer.de/${REPO}.git" \ - /workspace/repo + # Use Gitea token if available, otherwise try public access + if [ -n "${{ secrets.GITEA_TOKEN }}" ]; then + git clone --depth 1 --branch "$REF_NAME" \ + "https://${{ secrets.GITEA_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo + else + # Try public HTTPS (works if repository is public) + git clone --depth 1 --branch "$REF_NAME" \ + "https://git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo || \ + # Fallback: Try to use Gitea's internal runner access + git clone --depth 1 \ + "https://git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo + fi cd /workspace/repo @@ -118,16 +123,21 @@ jobs: REF_NAME="main" fi - # Try HTTPS first, fallback to SSH - git clone --depth 1 --branch "$REF_NAME" \ - "https://git.michaelschiemer.de/${REPO}.git" \ - /workspace/repo || \ - git clone --depth 1 --branch "$REF_NAME" \ - "git@git.michaelschiemer.de:${REPO}.git" \ - /workspace/repo || \ - git clone --depth 1 \ - "https://git.michaelschiemer.de/${REPO}.git" \ - /workspace/repo + # Use Gitea token if available, otherwise try public access + if [ -n "${{ secrets.GITEA_TOKEN }}" ]; then + git clone --depth 1 --branch "$REF_NAME" \ + "https://${{ secrets.GITEA_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo + else + # Try public HTTPS (works if repository is public) + git clone --depth 1 --branch "$REF_NAME" \ + "https://git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo || \ + # Fallback: Try to use Gitea's internal runner access + git clone --depth 1 \ + "https://git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo + fi cd /workspace/repo @@ -200,22 +210,23 @@ jobs: steps: - name: Checkout deployment scripts run: | - REF_NAME="${GITEA_REF_NAME:-main}" - REPO="${GITEA_REPOSITORY}" - SERVER_URL="${GITEA_SERVER_URL}" - - # Try HTTPS first, fallback to SSH - if [ -n "$REPO" ] && [ -n "$SERVER_URL" ]; then - git clone --depth 1 --branch "$REF_NAME" \ - "https://${SERVER_URL}/${REPO}.git" \ - /workspace/repo || true + REF_NAME="${{ github.ref_name }}" + REPO="${{ github.repository }}" + if [ -z "$REF_NAME" ]; then + REF_NAME="main" fi - # Fallback to SSH if HTTPS failed - if [ ! -d /workspace/repo ]; then + # Use Gitea token if available, otherwise try public access + if [ -n "${{ secrets.GITEA_TOKEN }}" ]; then git clone --depth 1 --branch "$REF_NAME" \ - "git@git.michaelschiemer.de:${REPO}.git" \ + "https://${{ secrets.GITEA_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \ + /workspace/repo + else + # Try public HTTPS (works if repository is public) + git clone --depth 1 --branch "$REF_NAME" \ + "https://git.michaelschiemer.de/${REPO}.git" \ /workspace/repo || \ + # Fallback: Try to use Gitea's internal runner access git clone --depth 1 \ "https://git.michaelschiemer.de/${REPO}.git" \ /workspace/repo