Tx stream resource balance change and transaction status filter (#817) #496
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync OpenAPI specs with Postman | |
on: | |
push: | |
branches: | |
- develop | |
workflow_dispatch: | |
inputs: | |
network_name: | |
description: "Testnet to publish collection for" | |
required: true | |
default: gilganet | |
options: | |
- gilganet | |
- enkinet | |
- hammunet | |
- adapanet | |
jobs: | |
cancel_running_workflows: | |
name: Cancel running workflows | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: cancel running workflows | |
uses: RDXWorks-actions/cancel-workflow-action@main | |
with: | |
access_token: ${{github.token}} | |
sync_collections: | |
name: Sync Postman collection w/ latest specs | |
environment: Postman | |
runs-on: ubuntu-22.04 | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Set current date | |
id: date | |
run: echo "date=$(date +'%b %d, %H:%M')" >> $GITHUB_OUTPUT | |
- name: Checkout gateway repo | |
uses: RDXWorks-actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- uses: ./.github/actions/fetch-secrets | |
with: | |
role_name: "arn:aws:iam::308190735829:role/gh-babylon-gateway-secrets-read-access" | |
app_name: "babylon-gateway" | |
step_name: "sync_collections" | |
secret_prefix: "POSTMAN_API" | |
secret_name: "github-actions/radixdlt/babylon-gateway/postman-token" | |
parse_json: true | |
- name: Set git tags | |
id: gittag | |
run: echo "gittag=$(git describe --tags --dirty)" >> $GITHUB_OUTPUT | |
# ========== Mapping the network name to postman-related variables ========== | |
- name: Map network name to its variables | |
uses: RDXWorks-actions/variable-mapper@master | |
with: | |
key: "${{ github.event.inputs.network_name || 'gilganet' }}" | |
map: | | |
{ | |
"gilganet": { | |
"gateway_api_collection_name": "Gateway API (${{steps.gittag.outputs.gittag}}) ${{steps.date.outputs.date}} UTC", | |
"gateway_api_collection_id": "14449947-f0543557-0b9e-43ef-ae62-dd640fbf5a35" | |
}, | |
"enkinet": { | |
"gateway_api_collection_name": "Enkinet Gateway API (${{steps.gittag.outputs.gittag}})", | |
"gateway_api_collection_id": "14449947-61a63b06-4f92-465c-a0f3-89d4e756e664" | |
}, | |
"hammunet": { | |
"gateway_api_collection_name": "Gateway API (${{steps.gittag.outputs.gittag}})", | |
"gateway_api_collection_id": "" | |
}, | |
"adapanet": { | |
"gateway_api_collection_name": "Adapanet [ALPHANET] Gateway API (${{steps.gittag.outputs.gittag}})", | |
"gateway_api_collection_id": "" | |
}, | |
".*": { | |
"gateway_api_collection_name": "Gateway API (${{steps.gittag.outputs.gittag}}) ${{steps.date.outputs.date}} UTC", | |
"gateway_api_collection_id": "14449947-f0543557-0b9e-43ef-ae62-dd640fbf5a35" | |
} | |
} | |
- name: Echo environment | |
run: echo ${{ env.environment }} | |
# ========== Credentials ========== | |
- name: Setup Postman credentials | |
uses: RDXWorks-actions/write-file-action@master | |
with: | |
path: .env | |
contents: POSTMAN_API_KEY=${{env.POSTMAN_API_TOKEN}} | |
write-mode: append | |
# ========== Actually updating the postman collection ========== | |
- name: Update Postman's Gateway API collection from the spec | |
run: | | |
npx @apideck/[email protected] -l src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml \ | |
--postmanUid ${{env.gateway_api_collection_id}} --syncPostman true --envFile .env | |
- name: Download the collection | |
run: | | |
curl -X GET -H "X-API-KEY:${{env.POSTMAN_API_TOKEN}}" https://api.getpostman.com/collections/${{env.gateway_api_collection_id}} > tmp.collection.json | |
- name: Update the collection name w/ timestamp and git tag | |
run: | | |
sed -i 's/"name":".*","description":"This/"name":"${{env.gateway_api_collection_name}}","description":"This/' tmp.collection.json | |
- name: Change the baseUrl variable name | |
run: | | |
sed -i 's/{{baseUrl}}/{{gatewayBaseUrl}}/g' tmp.collection.json | |
- name: Update the collection | |
run: | | |
curl -X PUT -H "X-API-KEY:${{env.POSTMAN_API_TOKEN}}" -H "Content-Type: application/json" \ | |
https://api.getpostman.com/collections/${{env.gateway_api_collection_id}} --data "@tmp.collection.json" |