Skip to content

Commit

Permalink
chore: updating workflow order
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Dec 18, 2024
1 parent 5d46da5 commit 097cec2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 63 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/.tools-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tools environment cleanup

on:
workflow_call:

jobs:
tools-cleanup:
name: Cleanup tools environment
environment: tools
runs-on: ubuntu-24.04
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.13"

- name: Remove the PR database
continue-on-error: true
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
# This removes a new pluggable database, user and service for the PR
for i in {1..5}; do
POD_NAME=$(oc get pods -l app=nr-forest-client-tools -l deployment=nr-forest-client-tools-legacydb -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
if [ -n "$POD_NAME" ]; then
echo "Pod found: $POD_NAME"
oc exec $POD_NAME -- /opt/oracle/removeDatabase "THE" "PR_${{ github.event.number }}"
break
else
echo "Pod not found, retrying in 10 seconds... ($i/5)"
sleep 10
fi
done
if [ -z "$POD_NAME" ]; then
echo "Failed to find the pod after 5 attempts."
fi
41 changes: 17 additions & 24 deletions .github/workflows/.tools-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Tools deployment

on:
workflow_call:
pull_request:

concurrency:
# PR open and close use the same group, allowing only one at a time
Expand Down Expand Up @@ -56,8 +56,8 @@ jobs:
sleep 5
done
deploy-tools:
name: Deploy Tools
deploy-oracle:
name: Deploy Oracle Database
needs: [pre-tools, builds]
environment: tools
runs-on: ubuntu-24.04
Expand All @@ -78,31 +78,24 @@ jobs:
-p ORACLEDB_USER_W=THE
-p ORACLEDB_PASSWORD_W=${{ secrets.ORACLEDB_PASSWORD_W }}
-p TAG=latest

remove-tools:
name: Remove database and user
needs: [deploy-oracle]
secrets: inherit
uses: ./.github/workflows/.tools-cleanup.yml

deploy-tools:
name: Deploy Tools
needs: [pre-tools, builds, deploy-oracle]
environment: tools
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.13"
- name: Remove the PR database
continue-on-error: true
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
# This removes a new pluggable database, user and service for the PR
for i in {1..5}; do
POD_NAME=$(oc get pods -l app=nr-forest-client-tools -l deployment=nr-forest-client-tools-legacydb -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
if [ -n "$POD_NAME" ]; then
echo "Pod found: $POD_NAME"
oc exec $POD_NAME -- /opt/oracle/removeDatabase "THE" "PR_${{ github.event.number }}"
break
else
echo "Pod not found, retrying in 10 seconds... ($i/5)"
sleep 10
fi
done
if [ -z "$POD_NAME" ]; then
echo "Failed to find the pod after 5 attempts."
fi

- name: Create the PR database
continue-on-error: true
Expand Down
36 changes: 4 additions & 32 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,7 @@ jobs:
cleanup: label
packages: backend database frontend legacy processor

tools-cleanup:
name: Cleanup tools environment
needs: [cleanup]
environment: tools
runs-on: ubuntu-24.04
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.13"

- name: Remove the PR database
continue-on-error: true
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
# This removes a new pluggable database, user and service for the PR
for i in {1..5}; do
POD_NAME=$(oc get pods -l app=nr-forest-client-tools -l deployment=nr-forest-client-tools-legacydb -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
if [ -n "$POD_NAME" ]; then
echo "Pod found: $POD_NAME"
oc exec $POD_NAME -- /opt/oracle/removeDatabase "THE" "PR_${{ github.event.number }}"
break
else
echo "Pod not found, retrying in 10 seconds... ($i/5)"
sleep 10
fi
done
if [ -z "$POD_NAME" ]; then
echo "Failed to find the pod after 5 attempts."
fi
remove-tools:
name: Remove database and user
secrets: inherit
uses: ./.github/workflows/.tools-cleanup.yml
9 changes: 2 additions & 7 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ jobs:
run: |
echo "url=${{ github.event.repository.name }}-$((${{ github.event.number }} % 50))-frontend.apps.silver.devops.gov.bc.ca" >> $GITHUB_OUTPUT
deploy-tools:
name: Tools Deployment
secrets: inherit
uses: ./.github/workflows/.tools-deploy.yml

builds:
name: Builds
runs-on: ubuntu-24.04
Expand All @@ -47,7 +42,7 @@ jobs:
deploy:
name: Deploy Application
needs: [builds, deploy-tools, vars]
needs: [builds, vars]
environment: dev
runs-on: ubuntu-24.04
steps:
Expand Down Expand Up @@ -238,7 +233,7 @@ jobs:

results:
name: PR Results
needs: [builds, deploy, tests, deploy-tools]
needs: [builds, deploy, tests]
if: always()
runs-on: ubuntu-24.04
steps:
Expand Down

0 comments on commit 097cec2

Please sign in to comment.