name: Trigger Desktop Build on: push: branches: [lotus] jobs: trigger: runs-on: ubuntu-latest steps: - name: Bump cinny submodule and trigger cinny-desktop build env: TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | 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 cd desktop git config user.email "ci@lotusguild.org" git config user.name "Lotus CI" git submodule update --init cinny git -C cinny fetch origin git -C cinny checkout "$CINNY_SHA" git add cinny if git diff --cached --quiet; then echo "Submodule pointer already correct" else git commit -m "chore: bump cinny submodule to ${CINNY_SHA:0:8}" git push origin main echo "Submodule bump pushed" fi cd .. # ── Step 3: update .cinny-version via Gitea contents API ──────────── # Actions-runner pushes don't trigger downstream workflows in Gitea. # A REST API file update creates a real user-attributed commit that does. FILE_SHA=$(echo "$CURRENT" | python3 -c \ "import sys,json; d=json.load(sys.stdin); print(d.get('sha',''))" \ 2>/dev/null || echo "") CONTENT=$(echo -n "$CINNY_SHA" | base64 -w 0) if [ -n "$FILE_SHA" ]; then curl -sf -X PUT \ "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"