Skip to content

Commit 6ee8f75

Browse files
committed
perf: add gh-db-migration-wait workflow
1 parent 367d3d9 commit 6ee8f75

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "GitHub: Database Migration Wait"
2+
3+
on:
4+
workflow_call:
5+
6+
# Special permissions required for OIDC authentication
7+
permissions:
8+
id-token: write
9+
contents: read
10+
actions: read
11+
12+
jobs:
13+
gh-db-migration-wait:
14+
name: 'GitHub: Database Migration Wait'
15+
runs-on: ubuntu-latest
16+
env:
17+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
18+
steps:
19+
- name: GitHub Configuration
20+
run: git config --global url."https://oauth2:${{ secrets.GH_TOKEN }}@github.com".insteadOf https://github.com
21+
22+
- name: Clone cicd-deployment-scripts
23+
run: git clone https://github.com/code-kern-ai/cicd-deployment-scripts.git
24+
25+
- name: Database Migration Wait
26+
shell: bash
27+
run: |
28+
bash cicd-deployment-scripts/gh/db_migration_wait.sh \
29+
-e "dev" \
30+
-w "K8: Test" \
31+
-i ${{ github.run_id }}

gh/db_migration_wait.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# !/bin/bash
2+
set -e
3+
4+
ENVIRONMENT_NAME="dev"
5+
K8_TEST_WORKFLOW_NAME="K8: Test"
6+
CURRENT_WORKFLOW_DATABASE_ID=""
7+
8+
while getopts e:w:i: flag
9+
do
10+
case "${flag}" in
11+
e) ENVIRONMENT_NAME=${OPTARG};;
12+
w) K8_TEST_WORKFLOW_NAME=${OPTARG};;
13+
i) CURRENT_WORKFLOW_DATABASE_ID=${OPTARG};;
14+
esac
15+
done
16+
17+
18+
RUNNING_DB_UPGRADE_WORKFLOW=""
19+
RUNNING_DB_UPGRADE_WORKFLOW_ID=$(gh run list \
20+
--json conclusion,databaseId,headBranch,status,workflowName \
21+
--jq '.[] | select(.workflowName=="'$K8_TEST_WORKFLOW_NAME'" and .status!="completed" and .headBranch!="'$ENVIRONMENT_NAME'" and .databaseId!="'$CURRENT_WORKFLOW_DATABASE_ID'") | .databaseId' \
22+
--repo code-kern-ai/refinery-gateway)
23+
24+
# while [ -z $RUNNING_DB_UPGRADE_WORKFLOW ]; do
25+
# RUNNING_DB_UPGRADE_WORKFLOW=$(gh run list \
26+
# --json conclusion,databaseId,headBranch,status,workflowName \
27+
# --jq '.[] | select(.workflowName=="'$K8_TEST_WORKFLOW_NAME'" and .status!="completed" and .headBranch!="'$ENVIRONMENT_NAME'" and .databaseId!="'$CURRENT_WORKFLOW_DATABASE_ID'")' \
28+
# --repo code-kern-ai/refinery-gateway)
29+
# echo "Waiting for running db upgrade workflow to complete ..."
30+
# if [ -z $RUNNING_DB_UPGRADE_WORKFLOW ]; then
31+
# sleep 5
32+
# fi
33+
# done
34+
gh run watch $RUNNING_DB_UPGRADE_WORKFLOW_ID --repo code-kern-ai/refinery-gateway

0 commit comments

Comments
 (0)