From bc75ecb227d00f105063a6b504699250fdd6bdc7 Mon Sep 17 00:00:00 2001 From: Chengming Li Date: Mon, 25 Mar 2024 00:13:19 -0700 Subject: [PATCH 1/5] test --- infra/app/templates/backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/app/templates/backend.yaml b/infra/app/templates/backend.yaml index e27b67d38..b3f874f96 100644 --- a/infra/app/templates/backend.yaml +++ b/infra/app/templates/backend.yaml @@ -64,4 +64,4 @@ spec: ports: - protocol: TCP port: {{ .Values.port }} - targetPort: {{ .Values.backend.port }} + targetPort: {{ .Values.backend.port }} \ No newline at end of file From 02f774d59677534425a212776f00e094968e54dd Mon Sep 17 00:00:00 2001 From: Chengming Li Date: Thu, 4 Apr 2024 18:51:39 -0700 Subject: [PATCH 2/5] test --- backend/src/scripts/update-catalog.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/scripts/update-catalog.ts b/backend/src/scripts/update-catalog.ts index a8df30b99..c52c77e76 100644 --- a/backend/src/scripts/update-catalog.ts +++ b/backend/src/scripts/update-catalog.ts @@ -15,7 +15,7 @@ const SIS_SECTION_URL = 'https://gateway.api.berkeley.edu/sis/v1/classes/section const semToTermId = (s: SemesterType) => { // term-id is computed by dropping the century digit of the year, then adding the term code - const termMap: { [key: string] : number} = {'Fall': 8, 'Spring': 2, 'Summer': 5} + const termMap: { [key: string]: number } = { 'Fall': 8, 'Spring': 2, 'Summer': 5 } return `${Math.floor(s.year / 1000)}${s.year % 100}${termMap[s.term]}` } @@ -31,13 +31,13 @@ const queryPages = async (url: string, params: any, headers: any, field: stri let resp: AxiosResponse>; try { - resp = await axios.get(url, { params: { 'page-number': page, ...params}, headers }); + resp = await axios.get(url, { params: { 'page-number': page, ...params }, headers }); } catch (err) { if (axios.isAxiosError(err) && err.response?.status === 404) { break; } else { console.log(`Unexpected err querying SIS API. Error: ${err}.`) - + if (retries > 0) { retries--; console.log(`Retrying...`) @@ -45,7 +45,7 @@ const queryPages = async (url: string, params: any, headers: any, field: stri } else { console.log(`Too many errors querying SIS API for courses. Terminating update...`) throw err; - } + } } } @@ -71,7 +71,7 @@ const updateCourses = async () => { const courses = await queryPages(SIS_COURSE_URL, params, headers, 'courses'); console.log("Updating database with new course data...") - + const bulkOps = courses.map(c => ({ replaceOne: { filter: { classDisplayName: c.classDisplayName }, @@ -95,7 +95,7 @@ const updateClasses = async () => { const activeSemesters = await SemesterModel.find({ active: true }).lean(); const classes: ClassType[] = []; - + for (const s of activeSemesters) { console.log(`Updating classses for ${s.term} ${s.year}...`) @@ -132,7 +132,7 @@ const updateSections = async () => { const activeSemesters = await SemesterModel.find({ active: true }).lean(); const sections: SectionType[] = []; - + for (const s of activeSemesters) { console.log(`Updating sections for ${s.term} ${s.year}...`) @@ -180,4 +180,4 @@ const updateSections = async () => { } process.exit(0); -})(); \ No newline at end of file +})(); From 12b4446b2f177724fed38c33367d847e015cf18d Mon Sep 17 00:00:00 2001 From: Chengming Li Date: Thu, 4 Apr 2024 19:05:40 -0700 Subject: [PATCH 3/5] test --- .github/workflows/cd-branch.yml | 16 ++++++++-------- .github/workflows/cd-master.yml | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cd-branch.yml b/.github/workflows/cd-branch.yml index eec3f0e16..73e4950d5 100644 --- a/.github/workflows/cd-branch.yml +++ b/.github/workflows/cd-branch.yml @@ -10,13 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: SSH into Hozer - uses: appleboy/ssh-action@v1.0.3 - with: - host: hozer-51.ocf.berkeley.edu - username: root - key: ${{ secrets.SSH_KEY }} - script: | + - name: SSH + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh -i ~/.ssh/id_rsa root@hozer-51.ocf.berkeley.edu << EOF cd /berkeleytime git checkout ${{ github.event.pull_request.head.sha }} git pull @@ -32,4 +31,5 @@ jobs: --set redisUri=redis://bt-dev-redis-master.bt.svc.cluster.local:6379 \ --set nodeEnv=development \ --set frontend.image.tag=${{ github.event.pull_request.head.sha }} \ - --set backend.image.tag=${{ github.event.pull_request.head.sha }} \ No newline at end of file + --set backend.image.tag=${{ github.event.pull_request.head.sha }} + EOF \ No newline at end of file diff --git a/.github/workflows/cd-master.yml b/.github/workflows/cd-master.yml index f8e784b99..37d20774f 100644 --- a/.github/workflows/cd-master.yml +++ b/.github/workflows/cd-master.yml @@ -10,13 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: SSH into Hozer - uses: appleboy/ssh-action@v1.0.3 - with: - host: hozer-51.ocf.berkeley.edu - username: root - key: ${{ secrets.SSH_KEY }} - script: | + - name: SSH + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh -i ~/.ssh/id_rsa root@hozer-51.ocf.berkeley.edu << EOF cd /berkeleytime git checkout master git pull @@ -27,4 +26,5 @@ jobs: docker push octoberkeleytime/bt-backend:latest docker push octoberkeleytime/bt-frontend:latest kubectl rollout restart deployment bt-staging-app-backend - kubectl rollout restart deployment bt-staging-app-frontend \ No newline at end of file + kubectl rollout restart deployment bt-staging-app-frontend + EOF \ No newline at end of file From 66aeaaf2f5d2e96c741c1a71a486e906bd865391 Mon Sep 17 00:00:00 2001 From: Chengming-Li <115936688+Chengming-Li@users.noreply.github.com> Date: Thu, 4 Apr 2024 19:23:27 -0700 Subject: [PATCH 4/5] Update cd-branch.yml --- .github/workflows/cd-branch.yml | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/.github/workflows/cd-branch.yml b/.github/workflows/cd-branch.yml index 73e4950d5..76ab281a3 100644 --- a/.github/workflows/cd-branch.yml +++ b/.github/workflows/cd-branch.yml @@ -10,26 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: SSH - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh -i ~/.ssh/id_rsa root@hozer-51.ocf.berkeley.edu << EOF - cd /berkeleytime - git checkout ${{ github.event.pull_request.head.sha }} - git pull - docker compose up --build -d - docker tag berkeleytime-backend octoberkeleytime/bt-backend:${{ github.event.pull_request.head.sha }} - docker tag berkeleytime-frontend octoberkeleytime/bt-frontend:${{ github.event.pull_request.head.sha }} - docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - docker push octoberkeleytime/bt-backend:${{ github.event.pull_request.head.sha }} - docker push octoberkeleytime/bt-frontend:${{ github.event.pull_request.head.sha }} - helm install bt-dev-app ./app --namespace=bt \ - --set host=${{ github.event.pull_request.head.sha }}.stanfurdtime.com \ - --set mongoUri=mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt \ - --set redisUri=redis://bt-dev-redis-master.bt.svc.cluster.local:6379 \ - --set nodeEnv=development \ - --set frontend.image.tag=${{ github.event.pull_request.head.sha }} \ - --set backend.image.tag=${{ github.event.pull_request.head.sha }} - EOF \ No newline at end of file + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install SSH client + run: apt-get update && apt-get install -y openssh-client + + - name: Run SSH command + run: | + ssh -i ${{ secrets.SSH_KEY }} root@hozer-51.ocf.berkeley.edu "echo test" From 80729e7536492988e76289020ee40d2ff6620d37 Mon Sep 17 00:00:00 2001 From: Chengming Li Date: Thu, 4 Apr 2024 19:23:58 -0700 Subject: [PATCH 5/5] test --- backend/src/scripts/update-catalog.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/scripts/update-catalog.ts b/backend/src/scripts/update-catalog.ts index c52c77e76..0cc041e5c 100644 --- a/backend/src/scripts/update-catalog.ts +++ b/backend/src/scripts/update-catalog.ts @@ -180,4 +180,4 @@ const updateSections = async () => { } process.exit(0); -})(); +})(); \ No newline at end of file