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: |