4444 TAG=$(curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
4545 "https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest" | jq -r '.tag_name // empty')
4646
47- # Check if we already processed this tag (check if branch exists)
47+ # Check if we already processed this tag
4848 if git ls-remote --exit-code --heads origin "sync-extension-$TAG"; then
4949 echo "Branch for $TAG already exists, skipping."
5050 echo "skip=true" >> $GITHUB_OUTPUT
@@ -70,19 +70,26 @@ jobs:
7070 mkdir -p extension-temp
7171 cd extension-temp
7272
73- echo "⬇️ Fetching release assets for $TAG from $REPO..."
73+ echo "⬇️ Fetching release info for $TAG from $REPO..."
7474
75- # 1. Get the URL for 'extension-files.tar.gz' specifically
76- # We query the release assets API and filter by name
77- ASSET_URL=$(curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
78- "https://api.github.com/repos/$REPO/releases/tags/$TAG" | \
79- jq -r '.assets[] | select(.name == "extension-files.tar.gz") | .browser_download_url')
75+ # Capture response to file for debugging
76+ curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
77+ "https://api.github.com/repos/$REPO/releases/tags/$TAG" > release.json
78+
79+ # Check if we got a valid release object
80+ if grep -q "Not Found" release.json; then
81+ echo "❌ Critical Error: Release tag $TAG not found in repo $REPO"
82+ cat release.json
83+ exit 1
84+ fi
85+
86+ # Robust extraction
87+ ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .browser_download_url')
8088
8189 if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
8290 echo "❌ Critical Error: extension-files.tar.gz not found in release assets!"
83- echo "Debug: Listing available assets..."
84- curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
85- "https://api.github.com/repos/$REPO/releases/tags/$TAG" | jq -r '.assets[].name'
91+ echo "Available assets:"
92+ cat release.json | jq -r '.assets[].name' || echo "No assets found or invalid JSON"
8693 exit 1
8794 fi
8895
@@ -137,15 +144,14 @@ jobs:
137144 run : |
138145 git add sentience-chrome/
139146
140- # Check if anything actually changed
141147 if git diff --staged --quiet; then
142148 echo "No changes detected."
143149 echo "changed=false" >> $GITHUB_OUTPUT
144150 else
145151 echo "Changes detected."
146152 echo "changed=true" >> $GITHUB_OUTPUT
147153
148- # Show staged files to verify binary files are included
154+ # Show staged files
149155 echo "📊 Staged file sizes:"
150156 git diff --staged --name-only | while read file; do
151157 if [ -f "$file" ]; then
@@ -159,7 +165,6 @@ jobs:
159165 if : steps.release.outputs.skip != 'true' && steps.changes.outputs.changed == 'true'
160166 uses : peter-evans/create-pull-request@v5
161167 with :
162- # Use PR_TOKEN if available, otherwise GITHUB_TOKEN
163168 token : ${{ secrets.PR_TOKEN || secrets.GITHUB_TOKEN }}
164169 commit-message : " chore: sync extension files from sentience-chrome ${{ steps.release.outputs.tag }}"
165170 title : " Sync Extension: ${{ steps.release.outputs.tag }}"
@@ -175,4 +180,4 @@ jobs:
175180 delete-branch : true
176181 labels : |
177182 automated
178- extension-sync
183+ extension-sync
0 commit comments