bcgov/common-object-management-service

View on GitHub
.github/actions/deploy-to-environment/action.yaml

Summary

Maintainability
Test Coverage
name: Deploy to Environment
description: Deploys an image to the defined environment
inputs:
  app_name:
    description: Application general Name
    required: true
  acronym:
    description: Application acronym
    required: true
  environment:
    description: Logical Github Environment
    required: true
  job_name:
    description: Job/Instance name
    required: true
  namespace_prefix:
    description: Openshift Namespace common prefix
    required: true
  namespace_environment:
    description: Openshift Namespace environment suffix
    required: true
  openshift_server:
    description: Openshift API Endpoint
    required: true
  openshift_token:
    description: Openshift Service Account Token
    required: true
  deploy_postgres:
    description: Should Postgres database be installed for this release
    default: "true"

runs:
  using: composite
  steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Login to OpenShift Cluster
      uses: redhat-actions/oc-login@v1
      with:
        openshift_server_url: ${{ inputs.openshift_server }}
        openshift_token: ${{ inputs.openshift_token }}
        insecure_skip_tls_verify: true
        namespace: ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}

    - name: set lower case owner name
      shell: bash
      run: |
        echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
      env:
        OWNER: "${{ github.repository_owner }}"

    - name: Helm Deploy
      shell: bash
      run: >-
        helm upgrade --install --atomic ${{ inputs.job_name }} ${{ inputs.app_name }}
        --namespace ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}
        --repo https://bcgov.github.io/common-object-management-service
        --values ./.github/environments/values.${{ inputs.environment }}.yaml
        --set image.repository=ghcr.io/$OWNER_LC
        --set image.tag=sha-$(git rev-parse --short HEAD)
        --set route.host=${{ inputs.acronym }}-${{ inputs.namespace_environment }}-${{ inputs.job_name }}.apps.silver.devops.gov.bc.ca
        --set postgres.name=postgres-${{ inputs.job_name }}
        --set postgres.enabled=${{ inputs.deploy_postgres }}
        --timeout 15m
        --wait

    - name: Wait on Deployment
      shell: bash
      run: |
        oc rollout --namespace ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }} status dc/${{ inputs.app_name }}-${{ inputs.job_name }} --watch=true