Skip to content

Commit

Permalink
GHA: explicitly install oc first
Browse files Browse the repository at this point in the history
oc no longer comes with ubuntu-latest image - see actions/runner-images#10636
  • Loading branch information
norrisng-bc committed Jan 3, 2025
1 parent 7d3c731 commit 9211884
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
17 changes: 11 additions & 6 deletions .github/actions/deploy-to-environment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/on-pr-closed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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}}')
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/on-pr-opened.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit 9211884

Please sign in to comment.