From 4e05ec39af7f79cab510433f144e737acba4f8a6 Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Mon, 16 Dec 2024 15:00:27 -0800 Subject: [PATCH] update pipeline title --- .github/workflows/dev-ci.yaml | 117 +++++++++++++++++++-------------- .github/workflows/prod-ci.yaml | 2 +- .github/workflows/test-ci.yaml | 64 +++++++++--------- 3 files changed, 101 insertions(+), 82 deletions(-) diff --git a/.github/workflows/dev-ci.yaml b/.github/workflows/dev-ci.yaml index 5e4e94640..30099649d 100644 --- a/.github/workflows/dev-ci.yaml +++ b/.github/workflows/dev-ci.yaml @@ -1,4 +1,4 @@ -name: TFRS New Pipeline Dev +name: TFRS New Pipeline Dev release-2.22.0 on: push: @@ -20,9 +20,37 @@ concurrency: cancel-in-progress: true jobs: + + install-oc: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + + - name: Set up cache for OpenShift CLI + id: cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc # Path where the `oc` binary will be installed + key: oc-cli-${{ runner.os }} + + - name: Install OpenShift CLI (if not cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz + tar -xvf openshift-client-linux.tar.gz + sudo mv oc /usr/local/bin/ + oc version --client + + - name: Confirm OpenShift CLI is Available + run: oc version --client + get-version: name: Get the version runs-on: ubuntu-latest + needs: [install-oc] outputs: VERSION: ${{ steps.get-version.outputs.VERSION }} @@ -47,12 +75,11 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 @@ -89,12 +116,11 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 @@ -131,12 +157,11 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 @@ -162,7 +187,7 @@ jobs: name: Build TFRS Celery runs-on: ubuntu-latest timeout-minutes: 60 - needs: [get-version, build-backend, build-frontend, build-scan-coordinator] + needs: [build-backend, build-frontend, build-scan-coordinator] env: BUILD_SUFFIX: ${{ needs.get-version.outputs.VERSION }} @@ -173,12 +198,11 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 @@ -204,7 +228,7 @@ jobs: name: Build TFRS scan-handler runs-on: ubuntu-latest timeout-minutes: 60 - needs: [get-version, build-backend, build-frontend, build-scan-coordinator] + needs: [build-backend, build-frontend, build-scan-coordinator] env: BUILD_SUFFIX: ${{ needs.get-version.outputs.VERSION }} @@ -215,12 +239,11 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 @@ -246,7 +269,7 @@ jobs: name: Build TFRS Notification Server runs-on: ubuntu-latest timeout-minutes: 60 - needs: [get-version, build-backend, build-frontend, build-scan-coordinator] + needs: [build-backend, build-frontend, build-scan-coordinator] env: BUILD_SUFFIX: ${{ needs.get-version.outputs.VERSION }} @@ -257,12 +280,11 @@ jobs: with: ref: ${{ env.GIT_REF }} - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 @@ -288,10 +310,8 @@ jobs: name: Deploy on Dev runs-on: ubuntu-latest timeout-minutes: 60 - # needs: [get-version] needs: [ - get-version, build-backend, build-frontend, build-celery, @@ -311,13 +331,6 @@ jobs: repository: bcgov-c/tenant-gitops-0ab226 ref: main ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} - - - name: Install OpenShift CLI - run: | - curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz - tar -xvf openshift-client-linux.tar.gz - sudo mv oc kubectl /usr/local/bin/ - oc version --client - name: Update tags uses: mikefarah/yq@v4.40.5 @@ -339,6 +352,12 @@ jobs: git commit -m "Update the image tag to ${{ env.BUILD_SUFFIX }} on Dev" git push + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: diff --git a/.github/workflows/prod-ci.yaml b/.github/workflows/prod-ci.yaml index 62dae19c5..b3f58d98d 100644 --- a/.github/workflows/prod-ci.yaml +++ b/.github/workflows/prod-ci.yaml @@ -1,4 +1,4 @@ -name: TFRS New Pipeline Prod +name: TFRS New Pipeline Prod release-2.22.0 on: workflow_dispatch: diff --git a/.github/workflows/test-ci.yaml b/.github/workflows/test-ci.yaml index b93c34624..bdf4869b3 100644 --- a/.github/workflows/test-ci.yaml +++ b/.github/workflows/test-ci.yaml @@ -1,4 +1,4 @@ -name: TFRS New Pipeline Test +name: TFRS New Pipeline Test release-2.22.0 on: workflow_dispatch: @@ -95,27 +95,27 @@ jobs: ref: main ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} - # - name: Update tags - # uses: mikefarah/yq@v4.40.5 - # with: - # cmd: | - # yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/backend/values-test.yaml - # yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/frontend/values-test.yaml - # yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/notification-server/values-test.yaml - # yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/celery/values-test.yaml - # yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/scan-coordinator/values-test.yaml - # yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/scan-handler/values-test.yaml - - # - name: GitHub Commit & Push - # shell: bash {0} - # run: | - # git config --global user.email "actions@github.com" - # git config --global user.name "GitHub Actions" - # git add -A - # git commit -m "Update the image tag to ${{ env.BUILD_SUFFIX }} on Test" - # git push - - - name: Restore oc command from Cßache + - name: Update tags + uses: mikefarah/yq@v4.40.5 + with: + cmd: | + yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/backend/values-test.yaml + yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/frontend/values-test.yaml + yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/notification-server/values-test.yaml + yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/celery/values-test.yaml + yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/scan-coordinator/values-test.yaml + yq -i '.image.tag = "${{ env.BUILD_SUFFIX }}"' tfrs/charts/scan-handler/values-test.yaml + + # - name: GitHub Commit & Push + # shell: bash {0} + # run: | + # git config --global user.email "actions@github.com" + # git config --global user.name "GitHub Actions" + # git add -A + # git commit -m "Update the image tag to ${{ env.BUILD_SUFFIX }} on Test" + # git push + + - name: Restore oc command from Cache uses: actions/cache@v4.2.0 with: path: /usr/local/bin/oc @@ -129,15 +129,15 @@ jobs: insecure_skip_tls_verify: true namespace: ${{ env.TOOLS_NAMESPACE }} - - name: Tag and deploy to Test - run: | - helm -n ${{ env.TEST_NAMESPACE }} list - # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-backend:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-backend:${{ env.BUILD_SUFFIX }} - # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-frontend:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-frontend:${{ env.BUILD_SUFFIX }} - # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-celery:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-celery:${{ env.BUILD_SUFFIX }} - # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-scan-coordinator:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-scan-coordinator:${{ env.BUILD_SUFFIX }} - # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-scan-handler:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-scan-handler:${{ env.BUILD_SUFFIX }} - # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-notification-server:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-notification-server:${{ env.BUILD_SUFFIX }} + # - name: Tag and deploy to Test + # run: | + # helm -n ${{ env.TEST_NAMESPACE }} list + # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-backend:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-backend:${{ env.BUILD_SUFFIX }} + # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-frontend:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-frontend:${{ env.BUILD_SUFFIX }} + # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-celery:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-celery:${{ env.BUILD_SUFFIX }} + # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-scan-coordinator:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-scan-coordinator:${{ env.BUILD_SUFFIX }} + # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-scan-handler:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-scan-handler:${{ env.BUILD_SUFFIX }} + # oc tag ${{ env.DEV_NAMESPACE }}/tfrs-notification-server:${{ env.BUILD_SUFFIX }} ${{ env.TEST_NAMESPACE }}/tfrs-notification-server:${{ env.BUILD_SUFFIX }} - name: Ask for approval for TFRS Test deployment uses: trstringer/manual-approval@v1.6.0 @@ -145,7 +145,7 @@ jobs: secret: ${{ github.TOKEN }} approvers: AlexZorkin,kuanfandevops,prv-proton,JulianForeman,kevin-hashimoto,dhaselhan minimum-approvals: 1 - issue-title: "TFRS ${{ env.GIT_REF }} Test Deployment at $(date '+%Y-%m-%d %H:%M:%S %Z')" + issue-title: eval ("TFRS ${{ env.GIT_REF }} Test Deployment at " + $(date '+%Y-%m-%d %H:%M:%S %Z') ) # - name: Helm Deployment # run: |