fix(ci): use workflow_dispatch to trigger cinny-desktop build
Replace the contents-API workaround with a direct workflow_dispatch call using ACTIONS_TOKEN (which has Actions:write scope). Cascade prevention in Gitea blocked all previous push-based approaches. The submodule bump is kept for correct SHA tracking in git history. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,66 +8,33 @@ jobs:
|
|||||||
trigger:
|
trigger:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Bump cinny submodule and trigger cinny-desktop build
|
- name: Bump cinny submodule in cinny-desktop
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
CINNY_SHA="${{ github.sha }}"
|
CINNY_SHA="${{ github.sha }}"
|
||||||
echo "New cinny SHA: $CINNY_SHA"
|
|
||||||
|
|
||||||
# ── Step 1: check if cinny-desktop is already at this SHA ──────────
|
|
||||||
CURRENT=$(curl -sf \
|
|
||||||
"https://code.lotusguild.org/api/v1/repos/LotusGuild/cinny-desktop/contents/.cinny-version" \
|
|
||||||
-H "Authorization: token $TOKEN" 2>/dev/null || echo "{}")
|
|
||||||
CURRENT_SHA=$(echo "$CURRENT" | python3 -c \
|
|
||||||
"import sys,json,base64; d=json.load(sys.stdin); \
|
|
||||||
print(base64.b64decode(d['content']).decode().strip() if 'content' in d else '')" \
|
|
||||||
2>/dev/null || echo "")
|
|
||||||
|
|
||||||
if [ "$CURRENT_SHA" = "$CINNY_SHA" ]; then
|
|
||||||
echo "cinny-desktop already at $CINNY_SHA — nothing to do"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Step 2: bump the git submodule pointer ──────────────────────────
|
|
||||||
git clone "https://x-access-token:$TOKEN@code.lotusguild.org/LotusGuild/cinny-desktop.git" desktop
|
git clone "https://x-access-token:$TOKEN@code.lotusguild.org/LotusGuild/cinny-desktop.git" desktop
|
||||||
cd desktop
|
cd desktop
|
||||||
git config user.email "ci@lotusguild.org"
|
git config user.email "ci@lotusguild.org"
|
||||||
git config user.name "Lotus CI"
|
git config user.name "Lotus CI"
|
||||||
|
|
||||||
git submodule update --init cinny
|
git submodule update --init cinny
|
||||||
git -C cinny fetch origin
|
git -C cinny fetch origin
|
||||||
git -C cinny checkout "$CINNY_SHA"
|
git -C cinny checkout "$CINNY_SHA"
|
||||||
|
|
||||||
git add cinny
|
git add cinny
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "Submodule pointer already correct"
|
echo "Submodule already at $CINNY_SHA"
|
||||||
else
|
else
|
||||||
git commit -m "chore: bump cinny submodule to ${CINNY_SHA:0:8}"
|
git commit -m "chore: bump cinny submodule to ${CINNY_SHA:0:8}"
|
||||||
git push origin main
|
git push origin main
|
||||||
echo "Submodule bump pushed"
|
|
||||||
fi
|
fi
|
||||||
cd ..
|
|
||||||
|
|
||||||
# ── Step 3: update .cinny-version via Gitea contents API ────────────
|
- name: Dispatch cinny-desktop release build
|
||||||
# Actions-runner pushes don't trigger downstream workflows in Gitea.
|
env:
|
||||||
# A REST API file update creates a real user-attributed commit that does.
|
TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
FILE_SHA=$(echo "$CURRENT" | python3 -c \
|
run: |
|
||||||
"import sys,json; d=json.load(sys.stdin); print(d.get('sha',''))" \
|
curl -sf -X POST \
|
||||||
2>/dev/null || echo "")
|
"https://code.lotusguild.org/api/v1/repos/LotusGuild/cinny-desktop/actions/workflows/release.yml/dispatches" \
|
||||||
CONTENT=$(echo -n "$CINNY_SHA" | base64 -w 0)
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
if [ -n "$FILE_SHA" ]; then
|
-d '{"ref":"main"}'
|
||||||
curl -sf -X PUT \
|
echo "Dispatched release.yml on cinny-desktop/main"
|
||||||
"https://code.lotusguild.org/api/v1/repos/LotusGuild/cinny-desktop/contents/.cinny-version" \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"message\":\"chore: trigger desktop build for cinny ${CINNY_SHA:0:8}\",\"content\":\"$CONTENT\",\"sha\":\"$FILE_SHA\"}"
|
|
||||||
else
|
|
||||||
curl -sf -X POST \
|
|
||||||
"https://code.lotusguild.org/api/v1/repos/LotusGuild/cinny-desktop/contents/.cinny-version" \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"message\":\"chore: trigger desktop build for cinny ${CINNY_SHA:0:8}\",\"content\":\"$CONTENT\"}"
|
|
||||||
fi
|
|
||||||
echo "release.yml triggered via API commit"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user