Skip to content

Commit

Permalink
GHA: explicitly install oc first
Browse files Browse the repository at this point in the history
ubuntu-latest image no longer includes oc - see actions/runner-images#10636
  • Loading branch information
norrisng-bc committed Jan 4, 2025
1 parent b69eb83 commit 30f59cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
18 changes: 12 additions & 6 deletions .github/actions/deploy-to-environment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/on-pr-closed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ jobs:
- name: Login to OpenShift Cluster
uses: redhat-actions/oc-login@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 Down

0 comments on commit 30f59cf

Please sign in to comment.