|
| 1 | +name: Deploy proxy to internal-dev |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version number" |
| 8 | + required: true |
| 9 | + pr_number: |
| 10 | + description: "PR Number for PR Environment" |
| 11 | + required: false |
| 12 | + |
| 13 | + |
| 14 | +jobs: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + deploy-internal-dev: |
| 17 | + name: Deploy to Internal Dev |
| 18 | + env: |
| 19 | + PROXYGEN_API_NAME: notify-supplier-api |
| 20 | + PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }} |
| 21 | + PR_NUMBER: ${{ github.event.inputs.pr_number }} |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: 24 |
| 29 | + |
| 30 | + - name: Npm install |
| 31 | + working-directory: . |
| 32 | + run: npm ci |
| 33 | + shell: bash |
| 34 | + |
| 35 | + - name: Setup Proxy Name and target |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + if [ -z $PR_NUMBER ] |
| 39 | + then |
| 40 | + echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV |
| 41 | + echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV |
| 42 | + echo "SANDBOX_TAG=latest" >> $GITHUB_ENV |
| 43 | + echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV |
| 44 | + else |
| 45 | + echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV |
| 46 | + echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV |
| 47 | + echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV |
| 48 | + echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV |
| 49 | + fi |
| 50 | +
|
| 51 | + - name: Install Proxygen client |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + # Install proxygen cli |
| 55 | + pip install pipx |
| 56 | + pipx install proxygen-cli |
| 57 | +
|
| 58 | + # Setup proxygen auth and settings |
| 59 | + mkdir -p ${HOME}/.proxygen |
| 60 | + echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key |
| 61 | + envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml |
| 62 | + envsubst < ./.github/proxygen-credentials-template.yaml | cat |
| 63 | + envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml |
| 64 | + envsubst < ./.github/proxygen-settings.yaml | cat |
| 65 | +
|
| 66 | + - name: Build internal dev oas |
| 67 | + working-directory: . |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + if [ -z $PR_NUMBER ] |
| 71 | + then |
| 72 | + make build-json-oas-spec APIM_ENV=internal-dev |
| 73 | + else |
| 74 | + make build-json-oas-spec APIM_ENV=internal-dev-pr |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Set target and cert |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + 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 |
| 81 | + 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 |
| 82 | +
|
| 83 | + - name: Deploy to Internal Dev |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm |
0 commit comments