|
| 1 | +name: Deploy to Dev and Sandbox |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + metadata: |
| 10 | + name: "Set CI/CD metadata" |
| 11 | + runs-on: ubuntu-latest |
| 12 | + timeout-minutes: 1 |
| 13 | + outputs: |
| 14 | + version: ${{ steps.variables.outputs.version }} |
| 15 | + steps: |
| 16 | + - name: "Set CI/CD variables" |
| 17 | + id: variables |
| 18 | + run: | |
| 19 | + echo "version=spec-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT |
| 20 | +
|
| 21 | + - name: "List variables" |
| 22 | + run: | |
| 23 | + echo "Deploying to: DEV & Sandbox" |
| 24 | + echo "VERSION=${{ steps.variables.outputs.version }}" |
| 25 | +
|
| 26 | + dev: |
| 27 | + needs: metadata |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v6 |
| 32 | + |
| 33 | + - name: Set up Python 3.11 |
| 34 | + uses: actions/setup-python@v6 |
| 35 | + with: |
| 36 | + python-version: '3.11' |
| 37 | + |
| 38 | + - name: Set up Node.js |
| 39 | + uses: actions/setup-node@v6 |
| 40 | + with: |
| 41 | + node-version: '20' |
| 42 | + |
| 43 | + - name: Install Poetry |
| 44 | + run: curl -sSL https://install.python-poetry.org | python3 - |
| 45 | + |
| 46 | + - name: Install Python and Node dependencies |
| 47 | + run: | |
| 48 | + make install |
| 49 | +
|
| 50 | + - name: Install proxygen-cli |
| 51 | + run: | |
| 52 | + pip install proxygen-cli |
| 53 | +
|
| 54 | + - name: Set up Proxygen credentials |
| 55 | + env: |
| 56 | + PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }} |
| 57 | + run: | |
| 58 | + mkdir -p ~/.proxygen |
| 59 | + echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api.pem |
| 60 | + make setup-proxygen-credentials |
| 61 | + - name: Generate specification |
| 62 | + run: | |
| 63 | + make construct-spec APIM_ENV=internal-dev |
| 64 | +
|
| 65 | + - name: Publish internal-dev spec to Proxygen |
| 66 | + run: | |
| 67 | + proxygen spec publish build/specification/internal-dev/eligibility-signposting-api.yaml --no-confirm |
| 68 | +
|
| 69 | + - name: Deploy internal-dev spec to Proxygen |
| 70 | + run: | |
| 71 | + proxygen instance deploy internal-dev eligibility-signposting-api build/specification/internal-dev/eligibility-signposting-api.yaml --no-confirm |
| 72 | +
|
| 73 | + sandbox: |
| 74 | + needs: dev |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - name: Checkout repository |
| 78 | + uses: actions/checkout@v6 |
| 79 | + |
| 80 | + - name: Set up Python 3.11 |
| 81 | + uses: actions/setup-python@v6 |
| 82 | + with: |
| 83 | + python-version: '3.11' |
| 84 | + |
| 85 | + - name: Set up Node.js |
| 86 | + uses: actions/setup-node@v6 |
| 87 | + with: |
| 88 | + node-version: '20' |
| 89 | + |
| 90 | + - name: Install Poetry |
| 91 | + run: curl -sSL https://install.python-poetry.org | python3 - |
| 92 | + |
| 93 | + - name: Install Python and Node dependencies |
| 94 | + run: | |
| 95 | + make install |
| 96 | +
|
| 97 | + - name: Install proxygen-cli |
| 98 | + run: | |
| 99 | + pip install proxygen-cli |
| 100 | +
|
| 101 | + - name: Set up Proxygen credentials |
| 102 | + env: |
| 103 | + PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }} |
| 104 | + run: | |
| 105 | + mkdir -p ~/.proxygen |
| 106 | + echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api.pem |
| 107 | + make setup-proxygen-credentials |
| 108 | + - name: Generate specification |
| 109 | + run: | |
| 110 | + make construct-spec APIM_ENV=sandbox |
| 111 | +
|
| 112 | + - name: Publish sandbox spec to Proxygen |
| 113 | + run: | |
| 114 | + proxygen spec publish build/specification/sandbox/eligibility-signposting-api.yaml --no-confirm |
| 115 | +
|
| 116 | + - name: Deploy sandbox spec to Proxygen |
| 117 | + run: | |
| 118 | + proxygen instance deploy sandbox eligibility-signposting-api build/specification/sandbox/eligibility-signposting-api.yaml --no-confirm |
| 119 | +
|
| 120 | + publish_postman: |
| 121 | + needs: sandbox |
| 122 | + runs-on: ubuntu-latest |
| 123 | + steps: |
| 124 | + - uses: actions/checkout@v6 |
| 125 | + - name: Install dependencies |
| 126 | + run: make install |
| 127 | + - name: Generate Postman Collection |
| 128 | + run: make convert-postman |
| 129 | + - name: Publish Postman Collection |
| 130 | + env: |
| 131 | + POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }} |
| 132 | + run: | |
| 133 | + curl --fail -X PUT \ |
| 134 | + https://api.getpostman.com/collections/{{YOUR_COLLECTION_UID}} \ |
| 135 | + -H "X-Api-Key: $POSTMAN_API_KEY" \ |
| 136 | + -H "Content-Type: application/json" \ |
| 137 | + -d @specification/postman/collection.json |
| 138 | +
|
| 139 | + publish: |
| 140 | + needs: publish_postman |
| 141 | + runs-on: ubuntu-latest |
| 142 | + steps: |
| 143 | + - name: "Tag the dev & sandbox deployment" |
| 144 | + run: | |
| 145 | + git config user.name "github-actions" |
| 146 | + git config user.email "github-actions@github.com" |
| 147 | + git tag ${{ needs.metadata.outputs.version }} |
| 148 | + git push origin ${{ needs.metadata.outputs.version }} |
| 149 | +
|
| 150 | + notify_slack: |
| 151 | + needs: publish |
| 152 | + runs-on: ubuntu-latest |
| 153 | + steps: |
| 154 | + - name: "Notify Slack on PR merge" |
| 155 | + uses: slackapi/slack-github-action@v2.1.1 |
| 156 | + with: |
| 157 | + webhook: ${{ secrets.SLACK_WORKFLOW_WEBHOOK_URL }} |
| 158 | + webhook-type: webhook-trigger |
| 159 | + payload: | |
| 160 | + status: "${{ job.status }}" |
| 161 | + link: "https://github.com/${{ github.repository }}/commit/${{ github.sha }}" |
| 162 | + triggered_by: "${{ github.actor }}" |
| 163 | + environment: "Specification updated in Dev & Sandbox" |
| 164 | + version: "${{ needs.metadata.outputs.version }}" |
0 commit comments