|
| 1 | +name: "Build Proxies" |
| 2 | +description: "Build an OAS file with sandbox settings" |
| 3 | +inputs: |
| 4 | + apim_env: |
| 5 | + description: "APIM Target environment: internal-dev, internal-dev-sandbox, int, prod" |
| 6 | + required: true |
| 7 | + backend_account: |
| 8 | + description: "The backend target account: dev, nonprod, prod" |
| 9 | + required: true |
| 10 | + pr_number: |
| 11 | + description: "Sandbox tag, one of: pr number, release tag, or latest" |
| 12 | + required: true |
| 13 | + api_name: |
| 14 | + description: "The instance name of the API in APIM" |
| 15 | + required: true |
| 16 | + |
| 17 | +runs: |
| 18 | + using: composite |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: 24 |
| 27 | + |
| 28 | + - name: Npm install |
| 29 | + working-directory: . |
| 30 | + run: npm ci |
| 31 | + shell: bash |
| 32 | + |
| 33 | + - name: Determing backend env |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + if [ -n "${{ inputs.pr_number }}" ]; then |
| 37 | + echo "BACKEND_ENV=pr${{ inputs.pr_number }}" >> $GITHUB_ENV |
| 38 | + else |
| 39 | + echo "BACKEND_ENV=main" >> $GITHUB_ENV |
| 40 | + fi |
| 41 | +
|
| 42 | + - name: Setup Proxy Name and target |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + echo "INSTANCE=${{ inputs.api_name }}-$BACKEND_ENV" >> $GITHUB_ENV |
| 46 | + echo "MTLS_NAME=notify-supplier-mtls-$BACKEND_ENV" >> $GITHUB_ENV |
| 47 | + echo "TARGET=https://$BACKEND_ENV.suppliers.${{ inputs.backend_account }}.nhsnotify.national.nhs.uk" >> $GITHUB_ENV |
| 48 | +
|
| 49 | + - name: Build oas for environment |
| 50 | + working-directory: . |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + make build-json-oas-spec APIM_ENV=${{ inputs.apim_env }} |
| 54 | +
|
| 55 | + - name: Set target and cert |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + jq --arg newurl "$TARGET" '.["x-nhsd-apim"].target.url = $newurl' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json |
| 59 | + jq --arg newmtls "$MTLS_NAME" '.["x-nhsd-apim"].target.security.secret = $newmtls' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json |
| 60 | +
|
| 61 | + - name: Rename artefact |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + mv build/notify-supplier.json build/notify-supplier-${{ inputs.apim-env }}.json |
| 65 | +
|
| 66 | + - name: Upload Sandbox Specification |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: api-specification |
| 70 | + path: ./build/notify-supplier-${{ inputs.apim-env }}.json |
0 commit comments