From c65bef22c2b426f0348fd395e86d812e8865a59e Mon Sep 17 00:00:00 2001 From: Om Mishra <32200996+mishraomp@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:51:26 -0800 Subject: [PATCH] fix: the pipeline and release process as we have pr numbers now as part of merge (#60) * fix pipeline * fix pipeline * fix the needs * fix the needs * fix release * fix pipeline * fix pipeline * fix names * fix helm command * remove not needed files * remove not needed files --- .github/workflows/.deploy.yml | 152 ---------------------------- .github/workflows/helm-release.yaml | 24 ----- 2 files changed, 176 deletions(-) delete mode 100644 .github/workflows/.deploy.yml delete mode 100644 .github/workflows/helm-release.yaml diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml deleted file mode 100644 index cd26ea6..0000000 --- a/.github/workflows/.deploy.yml +++ /dev/null @@ -1,152 +0,0 @@ -name: .Deploys - -on: - workflow_call: - inputs: - ### Required - release: - description: Deployment release; usually PR number, test or prod - required: true - type: string - - ### Typical / recommended - autoscaling: - description: Autoscaling enabled or not for the deployments - required: false - type: string - default: true - environment: - description: Environment name; omit for PRs - required: false - type: string - tag: - description: Container tag; usually PR number - required: false - type: string - default: ${{ github.event.number }} - triggers: - description: Paths to trigger a deploy; omit=always; e.g. ('backend/' 'frontend/') - required: false - type: string - - ### Usually a bad idea / not recommended - directory: - description: 'Chart directory' - default: 'charts/${{ github.event.repository.name }}' - required: false - type: string - timeout-minutes: - description: 'Timeout minutes' - default: 10 - required: false - type: number - values: - description: 'Values file' - default: 'values.yaml' - required: false - type: string - DB_HOST: - description: 'Database Host' - default: '' - required: true - type: string - DB_NAME: - description: 'Database Name' - default: '' - required: true - type: string - DB_PWD: - description: 'Database Password' - default: '' - required: true - type: string - DB_USER: - description: 'Database User' - default: '' - required: true - type: string - DB_PORT: - description: 'Database Port' - default: '1543' - required: false - type: string - params: - description: 'Extra parameters to pass to helm upgrade' - default: '' - required: false - type: string - -env: - repo_release: ${{ github.event.repository.name }}-${{ inputs.release }} - package_tag: ${{ inputs.tag }} - -jobs: - deploys: - name: Helm - environment: ${{ inputs.environment }} - runs-on: ubuntu-22.04 - timeout-minutes: ${{ inputs.timeout-minutes }} - steps: - - uses: actions/checkout@v4 - - name: Check Deployment Triggers - id: triggers - run: | - # Expand for trigger processing - - # Always deploy if no triggers are provided - if [ -z "${{ inputs.triggers }}" ]; then - echo "Always deploy when no triggers are provided" - echo "triggered=true" >> $GITHUB_OUTPUT - exit 0 - fi - - # Deploy if changed files (git diff) match triggers - TRIGGERS=${{ inputs.triggers }} - git fetch origin ${{ github.event.repository.default_branch }} - while read -r check; do - for t in "${TRIGGERS[@]}"; do - if [[ "${check}" =~ "${t}" ]]; then - echo "Build triggered based on git diff" - echo -e "${t}\n --> ${check}" - echo "triggered=true" >> $GITHUB_OUTPUT - exit 0 - fi - done - done < <(git diff origin/${{ github.event.repository.default_branch }} --name-only) - - # If here skip deployment - echo "No triggers have fired, deployment skipped" - - - name: Deploy if Triggers Fired - if: ${{ steps.triggers.outputs.triggered == 'true' }} - working-directory: ${{ inputs.directory }} - shell: bash - run: | - oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }} - oc project ${{ vars.OC_NAMESPACE }} # Safeguard! - # uninstall if found - helm uninstall ${{ env.repo_release }} || true - - # Deploy Helm Chart - helm dependency update - helm package --app-version="${{ env.package_tag }}" --version=${{ inputs.tag }} . - - helm upgrade \ - --set-string app.envs.DB_HOST=${{ inputs.DB_HOST }} \ - --set-string app.envs.DB_NAME=${{ inputs.DB_NAME }} \ - --set-string app.envs.DB_PASSWORD=${{ inputs.DB_PWD }} \ - --set-string app.envs.DB_USER=${{ inputs.DB_USER }} \ - --set-string app.envs.DB_PORT="${{ inputs.DB_PORT }}" \ - --set-string image.tag="${{ env.package_tag }}" \ - --set-string namespace=${{ vars.oc_namespace }} \ - ${{ inputs.params }} \ - --install --wait --atomic ${{ env.repo_release }} \ - --timeout ${{ inputs.timeout-minutes }}m \ - --values ${{ inputs.values }} \ - ./${{ github.event.repository.name }}-${{ inputs.tag }}.tgz - - # print history - helm history ${{ env.repo_release }} - - # Remove old build runs, build pods and deployment pods - oc delete po --field-selector=status.phase==Succeeded diff --git a/.github/workflows/helm-release.yaml b/.github/workflows/helm-release.yaml deleted file mode 100644 index e7d495c..0000000 --- a/.github/workflows/helm-release.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: helm release -on: - workflow_dispatch: -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -jobs: - helm-release: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.6.0 - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file