-
Notifications
You must be signed in to change notification settings - Fork 51
37 lines (29 loc) · 1.22 KB
/
sync-rooms.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Sync Rooms Postman Collection
on:
push:
branches:
- master # Change this to the branch you want to trigger the action
paths:
- 'assets/rooms-collection.json'
jobs:
update-postman:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Update Rooms Postman Collection
env:
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
run: |
# Run the Postman API to update the collection
GITHUB_COLLECTION_PATH="./assets/rooms-collection.json"
COLLECTION_UID=${{ vars.ROOMS_COLLECTION_UID }}
# Read the file content and wrap it inside a collection object
WRAPPED_CONTENT=$(jq -n --argfile data "$GITHUB_COLLECTION_PATH" '{"collection": $data}')
# Write the wrapped content to a temporary file
echo "$WRAPPED_CONTENT" > wrapped_collection.json
# Use curl with --data-binary to handle large file content
curl --location --request PUT "https://api.getpostman.com/collections/$COLLECTION_UID" \
--header "x-api-key: $POSTMAN_API_KEY" \
--header "Content-Type: application/json" \
--data-binary @wrapped_collection.json