From 5bf0e17a1067d9df2ea4ef42076a843198ae45f6 Mon Sep 17 00:00:00 2001 From: Norris Ng <103449568+norrisng-bc@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:38:01 -0800 Subject: [PATCH] GHA: explicitly install oc first ubuntu-latest image no longer includes oc - see https://github.com/actions/runner-images/issues/10636 --- .../actions/deploy-to-environment/action.yaml | 18 ++++++++++++------ .github/workflows/on-pr-closed.yaml | 17 +++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/actions/deploy-to-environment/action.yaml b/.github/actions/deploy-to-environment/action.yaml index 19c2751b..7b8cf5eb 100644 --- a/.github/actions/deploy-to-environment/action.yaml +++ b/.github/actions/deploy-to-environment/action.yaml @@ -32,13 +32,19 @@ runs: - name: Checkout repository uses: actions/checkout@v4 - - name: Login to OpenShift Cluster - uses: redhat-actions/oc-login@v1 + - name: Install CLI tools from OpenShift Mirror + uses: redhat-actions/openshift-tools-installer@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 }} + oc: "4" + + - name: Login to OpenShift and select project + shell: bash + run: | + # OC Login + OC_TEMP_TOKEN=$(curl -k -X POST ${{ inputs.openshift_server }}/api/v1/namespaces/${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}/serviceaccounts/pipeline/token --header "Authorization: Bearer ${{ inputs.openshift_token }}" -d '{"spec": {"expirationSeconds": 600}}' -H 'Content-Type: application/json; charset=utf-8' | jq -r '.status.token' ) + oc login --token=$OC_TEMP_TOKEN --server=${{ inputs.openshift_server }} + # move to project context + oc project ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }} - name: Helm Deploy shell: bash diff --git a/.github/workflows/on-pr-closed.yaml b/.github/workflows/on-pr-closed.yaml index 32ef8ff7..c3f31581 100644 --- a/.github/workflows/on-pr-closed.yaml +++ b/.github/workflows/on-pr-closed.yaml @@ -28,13 +28,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Login to OpenShift Cluster - uses: redhat-actions/oc-login@v1 + - name: Install CLI tools from OpenShift Mirror + uses: redhat-actions/openshift-tools-installer@v1 with: - openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} - openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} - insecure_skip_tls_verify: true - namespace: ${{ env.NAMESPACE_PREFIX }}-dev + oc: "4" + - name: Login to OpenShift and select project + shell: bash + run: | + # OC Login + OC_TEMP_TOKEN=$(curl -k -X POST ${{ secrets.OPENSHIFT_SERVER }}/api/v1/namespaces/${{ env.NAMESPACE_PREFIX }}-dev/serviceaccounts/pipeline/token --header "Authorization: Bearer ${{ secrets.OPENSHIFT_TOKEN }}" -d '{"spec": {"expirationSeconds": 600}}' -H 'Content-Type: application/json; charset=utf-8' | jq -r '.status.token' ) + oc login --token=$OC_TEMP_TOKEN --server=${{ secrets.OPENSHIFT_SERVER }} + # move to project context + oc project ${{ env.NAMESPACE_PREFIX }}-dev - name: Remove PR Deployment shell: bash run: |