From 25a4efc857761180daa973715a0b93862babd90a Mon Sep 17 00:00:00 2001 From: KalyanaVadlamani <159027167+KalyanaVadlamani@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:11:13 +0000 Subject: [PATCH] Heat 227 (#10) Updated pipeline, removed unwanted variable from health_ping --- .github/workflows/deploy.yml | 15 ++++++++++++++- .github/workflows/pipeline.yml | 25 +++++++++++++++++++++++-- health_ping.py | 11 ++++++++++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b4820a8..9f9774d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,7 @@ on: required: true options: - dev + - prod version: description: Image version type: string @@ -41,12 +42,14 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false + matrix: + environment: [development, production] environment: name: ${{ inputs.github_environment }} steps: - uses: actions/checkout@v3 - - name: Deploy to Cloud Platform + - name: Deploy to Dev uses: ./.github/actions/cloud-platform-deploy with: environment: ${{ inputs.environment }} @@ -57,3 +60,13 @@ jobs: namespace: ${{ secrets.DEVELOPMENT_KUBE_NAMESPACE }} token: ${{ secrets.DEVELOPMENT_KUBE_TOKEN }} + - name: Deploy to Prod + uses: ./.github/actions/cloud-platform-deploy + with: + environment: ${{ inputs.environment }} + version: ${{ inputs.version }} + api: https://${{ secrets.PRODUCTION_KUBE_CLUSTER }} + cert: ${{ secrets.PRODUCTION_KUBE_CERT }} + cluster: ${{ secrets.PRODUCTION_KUBE_CLUSTER }} + namespace: ${{ secrets.PRODUCTION_KUBE_NAMESPACE }} + token: ${{ secrets.PRODUCTION_KUBE_TOKEN }} diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 85345bd..1bfb42b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -5,7 +5,15 @@ on: branches: - main workflow_dispatch: # Can be triggered manually from a branch - + inputs: + environment: + description: 'Deployment Environment (valid values: "development", "production")' + required: true + default: 'development' + version: + description: 'Application version to deploy' + required: true + jobs: build: name: Build @@ -13,8 +21,9 @@ jobs: with: push: true secrets: inherit + - deploy-to-dev: + deploy_to_dev: name: Deploy to dev uses: ./.github/workflows/deploy.yml needs: build @@ -22,4 +31,16 @@ jobs: github_environment: development environment: dev version: ${{ needs.build.outputs.version }} + secrets: inherit + + + deploy_to_prod: + name: Deploy to prod + uses: ./.github/workflows/deploy.yml + needs: + - deploy_to_dev # wait for the deploy_to_dev job to complete + with: + github_environment: production + environment: prod + version: ${{ github.event.inputs.version }} secrets: inherit \ No newline at end of file diff --git a/health_ping.py b/health_ping.py index c2e63bb..e106fa1 100644 --- a/health_ping.py +++ b/health_ping.py @@ -12,7 +12,6 @@ import socketserver sc_api_endpoint = os.getenv("SERVICE_CATALOGUE_API_ENDPOINT") -sc_api_filter = os.getenv("SC_FILTER", '') sc_api_token = os.getenv("SERVICE_CATALOGUE_API_KEY") redis_host = os.getenv("REDIS_ENDPOINT") redis_port = os.getenv("REDIS_PORT") @@ -22,6 +21,16 @@ refresh_interval = int(os.getenv("REFRESH_INTERVAL","60")) log_level = os.environ.get('LOG_LEVEL', 'INFO').upper() +# limit results for testing/dev +# See strapi filter syntax https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication +# Example filter string = '&filters[name][$contains]=example' +# sc_api_filter = '&filters[name][$contains]=book-a-prison-visit-staff-ui' +sc_api_filter = os.getenv("SERVICE_CATALOGUE_FILTER", '') + +# Example Sort filter +#SC_SORT='&sort=updatedAt:asc' + + def update_sc_component(c_id, data): try: log.debug(f"Data to POST to strapi {data}")