Skip to content

Merge pull request #403 from radixdlt/transaction-message #227

Merge pull request #403 from radixdlt/transaction-message

Merge pull request #403 from radixdlt/transaction-message #227

Workflow file for this run

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: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5
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: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b
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: kanga333/variable-mapper@3681b75f5c6c00162721168fb91ab74925eaebcb
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: DamianReeves/write-file-action@a432935930b2e351ec2d2792fc220717b656ec1c
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"