Proxygen Deployment for internal-dev #37
This file contains hidden or 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: Deploy proxy to environment | |
| run-name: Proxygen Deployment for ${{ inputs.proxy_environment }} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| proxy_environment: | |
| description: Name of the proxygen environment to deploy to | |
| required: true | |
| type: choice | |
| default: internal-dev | |
| options: | |
| - internal-dev | |
| - int | |
| - prod | |
| build_sandbox: | |
| description: Build sandbox container? | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: read | |
| packages: read | |
| jobs: | |
| deploy-environment: | |
| runs-on: ubuntu-latest | |
| name: Deploy to Environment | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Npm install | |
| working-directory: . | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npm ci | |
| shell: bash | |
| - name: "Check if pull request exists for this branch and set ENVIRONMENT/APIM_ENV" | |
| id: pr_exists | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')} | |
| echo "Current branch is '$branch_name'" | |
| if [ -z "${{ inputs.proxy_environment }}" ]; then | |
| ENVIRONMENT="internal-dev" | |
| else | |
| ENVIRONMENT="${{ inputs.proxy_environment }}" | |
| fi | |
| pr_json=$(gh pr list --head "$branch_name" --state open --json number --limit 1) | |
| pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty') | |
| if [[ -n "$pr_number" ]]; then | |
| echo "Pull request exists: #$pr_number" | |
| echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT | |
| echo "pr_number=$pr_number" >> $GITHUB_OUTPUT | |
| APIM_ENV="$ENVIRONMENT-pr" | |
| echo "changing environment variable so that PR number is used in proxy pipeline for setting env vars" | |
| ENVIRONMENT="pr$pr_number" | |
| else | |
| echo "Pull request doesn't exist, setting target env to main" | |
| echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT | |
| echo "pr_number=" >> $GITHUB_OUTPUT | |
| APIM_ENV="$ENVIRONMENT" | |
| ENVIRONMENT="main" | |
| fi | |
| echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV | |
| echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV | |
| - name: "Build OAS spec" | |
| uses: ./.github/actions/build-oas-spec | |
| with: | |
| apimEnv: "${{ env.APIM_ENV }}" | |
| buildSandbox: ${{ inputs.build_sandbox }} | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "Build proxies" | |
| env: | |
| PROXYGEN_API_NAME: nhs-notify-supplier | |
| PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }} | |
| APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }} | |
| APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }} | |
| uses: ./.github/actions/build-proxies | |
| with: | |
| environment: "${{ env.ENVIRONMENT }}" | |
| apimEnv: "${{ env.APIM_ENV }}" | |
| runId: "${{ github.run_id }}" | |
| buildSandbox: ${{ inputs.build_sandbox }} | |
| releaseVersion: ${{ github.ref_name }} |