diff --git a/.github/actions/deploy-to-environment/action.yaml b/.github/actions/deploy-to-environment/action.yaml index e250be6c..b9af6eac 100644 --- a/.github/actions/deploy-to-environment/action.yaml +++ b/.github/actions/deploy-to-environment/action.yaml @@ -35,13 +35,18 @@ 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: set lower case owner name shell: bash diff --git a/.github/workflows/on-pr-closed.yaml b/.github/workflows/on-pr-closed.yaml index 09fcea51..f56119a2 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: | @@ -51,7 +56,7 @@ jobs: CURRENT_USERS=$(oc get PostgresCluster/postgres-master -o json | jq '.spec.users') echo "${CURRENT_USERS}" - # Remove the user from the list, + # Remove the user from the list, UPDATED_USERS=$(echo "${CURRENT_USERS}" | jq --argjson user "${USER_TO_REMOVE}" 'map(select(. != $user))') PATCH_JSON=$(jq -n --argjson users "${UPDATED_USERS}" '{"spec": {"users": $users}}') diff --git a/.github/workflows/on-pr-opened.yaml b/.github/workflows/on-pr-opened.yaml index e5588315..b74d9773 100644 --- a/.github/workflows/on-pr-opened.yaml +++ b/.github/workflows/on-pr-opened.yaml @@ -44,14 +44,18 @@ jobs: needs: build timeout-minutes: 12 # increase for crunchyDB ? steps: - # TODO: does pr-123 user need to own database pr-123 in order to connect run knex migrations? - - 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: Add PR specific user to Crunchy DB shell: bash run: |