@@ -60,48 +60,55 @@ jobs:
6060 # Clone the searchindex repo
6161 git clone https://x-access-token:${TOKEN}@github.com/${TARGET_REPO}.git /tmp/searchindex-repo
6262
63+ cd /tmp/searchindex-repo
64+ git config user.name "GitHub Actions"
65+ git config user.email "[email protected] " 66+
67+ # Create a fresh orphan branch (no history)
68+ git checkout --orphan new-main
69+
70+ # Remove all existing files from git index
71+ git rm -rf . 2>/dev/null || true
72+
6373 # Copy and compress the searchindex file
64- cp "$ASSET" "/tmp/searchindex-repo/ ${FILENAME}"
74+ cp "$ASSET" "${FILENAME}"
6575 gzip -9 -k -f "$ASSET"
66- cp "${ASSET}.gz" "/tmp/searchindex-repo/ ${FILENAME}.gz"
76+ cp "${ASSET}.gz" "${FILENAME}.gz"
6777
6878 # Show compression stats
6979 ORIGINAL_SIZE=$(wc -c < "$ASSET")
7080 COMPRESSED_SIZE=$(wc -c < "${ASSET}.gz")
7181 RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
7282 echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
7383
74- # Commit and push with retry logic
75- cd /tmp/searchindex-repo
76- git config user.name "GitHub Actions"
77- git config user.email "[email protected] " 78- git add "${FILENAME}" "${FILENAME}.gz"
84+ # Add all files from other workflows (if they exist)
85+ git checkout main -- . 2>/dev/null || true
7986
80- if git diff --staged --quiet; then
81- echo "No changes to commit"
82- else
83- git commit -m "Update ${FILENAME} from hacktricks-cloud build"
84-
85- # Retry push up to 20 times with pull --rebase between attempts
86- MAX_RETRIES=20
87- RETRY_COUNT=0
88- while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
89- if git push origin main; then
90- echo "Successfully pushed on attempt $((RETRY_COUNT + 1))"
91- break
92- else
93- RETRY_COUNT=$((RETRY_COUNT + 1))
94- if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
95- echo "Push failed, attempt $RETRY_COUNT/$MAX_RETRIES. Pulling and retrying..."
96- git pull --rebase origin main
97- sleep $((RETRY_COUNT * 2)) # Exponential backoff
98- else
99- echo "Failed to push after $MAX_RETRIES attempts"
100- exit 1
101- fi
102- fi
103- done
87+ # Add our new files (will overwrite if they existed)
88+ cp "$ASSET" "${FILENAME}"
89+ cp "${ASSET}.gz" "${FILENAME}.gz"
90+
91+ # Create README if it doesn't exist
92+ if [ ! -f "README.md" ]; then
93+ echo "# HackTricks Search Index Repository" > README.md
94+ echo "" >> README.md
95+ echo "This repository contains searchindex files for HackTricks and HackTricks Cloud." >> README.md
96+ echo "Files are automatically generated and updated by GitHub Actions." >> README.md
97+ echo "" >> README.md
98+ echo "⚠️ This repository is reset periodically to keep history clean." >> README.md
10499 fi
100+
101+ # Stage all files
102+ git add -A
103+
104+ # Commit with timestamp
105+ TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
106+ git commit -m "Update searchindex files - ${TIMESTAMP}"
107+
108+ # Force push to replace main branch (deletes history)
109+ git push -f origin new-main:main
110+
111+ echo "Successfully reset repository and pushed searchindex files"
105112
106113 # Login in AWs
107114 - name : Configure AWS credentials using OIDC
0 commit comments