|
| 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 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v6 |
| 30 | + - uses: actions/setup-python@v6 |
| 31 | + with: |
| 32 | + python-version: '3.11' |
| 33 | + - uses: actions/setup-node@v6 |
| 34 | + with: |
| 35 | + node-version: '20' |
| 36 | + - run: make install |
| 37 | + - run: make construct-spec APIM_ENV=dev |
| 38 | + - run: make publish-spec APIM_ENV=dev |
| 39 | + - run: make deploy-spec APIM_ENV=dev |
| 40 | + |
| 41 | + sandbox: |
| 42 | + needs: dev |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v6 |
| 46 | + - uses: actions/setup-python@v6 |
| 47 | + with: |
| 48 | + python-version: '3.11' |
| 49 | + - uses: actions/setup-node@v6 |
| 50 | + with: |
| 51 | + node-version: '20' |
| 52 | + - run: make install |
| 53 | + - run: make construct-spec APIM_ENV=sandbox |
| 54 | + - run: make generate-sandbox-spec |
| 55 | + - run: make deploy-sandbox-spec |
| 56 | + - run: make build-and-publish-sandbox-image |
| 57 | + |
| 58 | + publish_postman: |
| 59 | + needs: sandbox |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v6 |
| 63 | + - name: Install dependencies |
| 64 | + run: make install |
| 65 | + - name: Generate Postman Collection |
| 66 | + run: make convert-postman |
| 67 | + - name: Publish Postman Collection |
| 68 | + env: |
| 69 | + POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }} |
| 70 | + run: | |
| 71 | + curl --fail -X PUT \ |
| 72 | + https://api.getpostman.com/collections/{{YOUR_COLLECTION_UID}} \ |
| 73 | + -H "X-Api-Key: $POSTMAN_API_KEY" \ |
| 74 | + -H "Content-Type: application/json" \ |
| 75 | + -d @specification/postman/collection.json |
| 76 | +
|
| 77 | + publish: |
| 78 | + needs: publish_postman |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: "Tag the dev & sandbox deployment" |
| 82 | + run: | |
| 83 | + git config user.name "github-actions" |
| 84 | + git config user.email "github-actions@github.com" |
| 85 | + git tag ${{ needs.metadata.outputs.version }} |
| 86 | + git push origin ${{ needs.metadata.outputs.version }} |
| 87 | +
|
| 88 | + notify_slack: |
| 89 | + needs: publish |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - name: "Notify Slack on PR merge" |
| 93 | + uses: slackapi/slack-github-action@v2.1.1 |
| 94 | + with: |
| 95 | + webhook: ${{ secrets.SLACK_WORKFLOW_WEBHOOK_URL }} |
| 96 | + webhook-type: webhook-trigger |
| 97 | + payload: | |
| 98 | + status: "${{ job.status }}" |
| 99 | + link: "https://github.com/${{ github.repository }}/commit/${{ github.sha }}" |
| 100 | + triggered_by: "${{ github.actor }}" |
| 101 | + environment: "Specification updated in Dev & Sandbox" |
| 102 | + version: "${{ needs.metadata.outputs.version }}" |
0 commit comments