Skip to content

Commit 414e4dc

Browse files
committed
ci: add workflow to accept crate owner invitations
Temporary workflow to accept pending crate owner invitations using the org-level CARGO_REGISTRY_TOKEN. This is needed to publish near-openapi-types and near-openapi-client under the nearprotocol-ci crates.io account.
1 parent 76a2e0e commit 414e4dc

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Accept crate owner invitations
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
accept-invites:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: List and accept pending crate owner invitations
11+
env:
12+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
13+
run: |
14+
set -euo pipefail
15+
16+
echo "Listing pending invitations..."
17+
RESPONSE=$(curl -s -H "Authorization: $CARGO_REGISTRY_TOKEN" \
18+
-H "User-Agent: near-api-rs-ci" \
19+
https://crates.io/api/v1/me/crate_owner_invitations)
20+
21+
echo "$RESPONSE" | jq .
22+
23+
INVITES=$(echo "$RESPONSE" | jq -c '.crate_owner_invitations // []')
24+
COUNT=$(echo "$INVITES" | jq length)
25+
26+
if [ "$COUNT" -eq 0 ]; then
27+
echo "No pending invitations found."
28+
exit 0
29+
fi
30+
31+
echo "Found $COUNT pending invitation(s). Accepting..."
32+
33+
echo "$INVITES" | jq -c '.[]' | while read -r invite; do
34+
CRATE_ID=$(echo "$invite" | jq '.crate_id')
35+
CRATE_NAME=$(echo "$invite" | jq -r '.crate_name')
36+
echo "Accepting invite for $CRATE_NAME (id: $CRATE_ID)..."
37+
38+
curl -s -X PUT \
39+
-H "Authorization: $CARGO_REGISTRY_TOKEN" \
40+
-H "Content-Type: application/json" \
41+
-H "User-Agent: near-api-rs-ci" \
42+
"https://crates.io/api/v1/me/crate_owner_invitations/$CRATE_ID" \
43+
-d "{\"crate_owner_invite\":{\"crate_id\":$CRATE_ID,\"accepted\":true}}" | jq .
44+
45+
echo "Done with $CRATE_NAME"
46+
done
47+
48+
echo "All invitations processed."

0 commit comments

Comments
 (0)