From 49b9a877a3241b93178cb619355b9c1421209f8c Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 20:56:23 -0500 Subject: [PATCH 01/33] Add GitHub Actions workflow to push Docker image to GHCR --- .github/workflows/pushtoghcr.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/pushtoghcr.yml diff --git a/.github/workflows/pushtoghcr.yml b/.github/workflows/pushtoghcr.yml new file mode 100644 index 00000000..f9952939 --- /dev/null +++ b/.github/workflows/pushtoghcr.yml @@ -0,0 +1,25 @@ +name: Push to GHCR + +on: + push: + branches: + - main + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: myimage + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/myimage.tar + docker image ls -a \ No newline at end of file From be138aa67fdc9f40bf64f7b88af6edfc75f48dee Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 20:57:27 -0500 Subject: [PATCH 02/33] Update GitHub Actions workflow to trigger on CI completion --- .github/workflows/pushtoghcr.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pushtoghcr.yml b/.github/workflows/pushtoghcr.yml index f9952939..ec21f599 100644 --- a/.github/workflows/pushtoghcr.yml +++ b/.github/workflows/pushtoghcr.yml @@ -1,9 +1,10 @@ name: Push to GHCR on: - push: - branches: - - main + workflow_run: + workflows: ["CI"] + types: + - completed workflow_dispatch: # Allows manual triggering of the workflow jobs: @@ -12,7 +13,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: Download artifact uses: actions/download-artifact@v4 with: From 9000bcd93df30279d598b64d8463172fd9ada12b Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 20:58:00 -0500 Subject: [PATCH 03/33] Only run GHCR push on main branch --- .github/workflows/pushtoghcr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pushtoghcr.yml b/.github/workflows/pushtoghcr.yml index ec21f599..d46cb669 100644 --- a/.github/workflows/pushtoghcr.yml +++ b/.github/workflows/pushtoghcr.yml @@ -2,7 +2,10 @@ name: Push to GHCR on: workflow_run: - workflows: ["CI"] + workflows: + - CI + branches: + - main types: - completed workflow_dispatch: # Allows manual triggering of the workflow From 350c950b3aba52ecb65b72b07215a4a69effbe6c Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:05:09 -0500 Subject: [PATCH 04/33] Refactor GitHub Actions workflow to use consistent artifact naming for Docker image --- .github/workflows/pushtoghcr.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pushtoghcr.yml b/.github/workflows/pushtoghcr.yml index d46cb669..52bca5e0 100644 --- a/.github/workflows/pushtoghcr.yml +++ b/.github/workflows/pushtoghcr.yml @@ -2,8 +2,7 @@ name: Push to GHCR on: workflow_run: - workflows: - - CI + workflows: ["CI"] branches: - main types: @@ -16,14 +15,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: Download artifact uses: actions/download-artifact@v4 with: - name: myimage + name: gearbox path: /tmp - name: Load image run: | - docker load --input /tmp/myimage.tar + docker load --input /tmp/gearbox.tar docker image ls -a \ No newline at end of file From 9bf259f5f0229b48223926656da54de24e33b799 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:10:43 -0500 Subject: [PATCH 05/33] Change artifact file path --- .github/workflows/pushtoghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pushtoghcr.yml b/.github/workflows/pushtoghcr.yml index 52bca5e0..aef73ac8 100644 --- a/.github/workflows/pushtoghcr.yml +++ b/.github/workflows/pushtoghcr.yml @@ -20,7 +20,7 @@ jobs: uses: actions/download-artifact@v4 with: name: gearbox - path: /tmp + path: /tmp/gearbox.tar - name: Load image run: | From 93dd81f870c7f64a432c0a71be569d785cab2e95 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:14:44 -0500 Subject: [PATCH 06/33] Create a combined CI/CD workflow --- .github/workflows/{ci.yml => cicd.yml} | 23 ++++++++++++++++++++- .github/workflows/pushtoghcr.yml | 28 -------------------------- 2 files changed, 22 insertions(+), 29 deletions(-) rename .github/workflows/{ci.yml => cicd.yml} (65%) delete mode 100644 .github/workflows/pushtoghcr.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/cicd.yml similarity index 65% rename from .github/workflows/ci.yml rename to .github/workflows/cicd.yml index a31855c4..e0c491c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/cicd.yml @@ -46,4 +46,25 @@ jobs: run: npm install - name: Unit Tests - run: npm run test \ No newline at end of file + run: npm run test + + push_to_ghcr: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + needs: + - build + - unit_test + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: gearbox + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/gearbox.tar + docker image ls -a \ No newline at end of file diff --git a/.github/workflows/pushtoghcr.yml b/.github/workflows/pushtoghcr.yml deleted file mode 100644 index aef73ac8..00000000 --- a/.github/workflows/pushtoghcr.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Push to GHCR - -on: - workflow_run: - workflows: ["CI"] - branches: - - main - types: - - completed - workflow_dispatch: # Allows manual triggering of the workflow - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: gearbox - path: /tmp/gearbox.tar - - - name: Load image - run: | - docker load --input /tmp/gearbox.tar - docker image ls -a \ No newline at end of file From 1708ff6a8cae877b10efe1940a988571b1f19854 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:15:47 -0500 Subject: [PATCH 07/33] Rename CI workflow to CI/CD --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e0c491c3..b8169e05 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -1,4 +1,4 @@ -name: CI +name: CI/CD on: push: From 68e7ee765b072f4da7d3e8e21a903db92eaeca75 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:22:11 -0500 Subject: [PATCH 08/33] Added step to push to GHCR --- .github/workflows/cicd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index b8169e05..c09e7ec9 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -67,4 +67,7 @@ jobs: - name: Load image run: | docker load --input /tmp/gearbox.tar - docker image ls -a \ No newline at end of file + docker image ls -a + + - name: Push to GHCR + run: docker push ghcr.io/Decatur-Robotics/gearbox:latest \ No newline at end of file From 50e4e0728766b5919cf90160574d1da0ebc55086 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:27:43 -0500 Subject: [PATCH 09/33] Made ghcr namespace lowercase --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index c09e7ec9..d752d2e7 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -70,4 +70,4 @@ jobs: docker image ls -a - name: Push to GHCR - run: docker push ghcr.io/Decatur-Robotics/gearbox:latest \ No newline at end of file + run: docker push ghcr.io/decatur-robotics/gearbox:latest \ No newline at end of file From bc7a26c9639039b599b38f196b0856945fcf9822 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:36:59 -0500 Subject: [PATCH 10/33] Changed tags for Docker build --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index d752d2e7..d1bb8306 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -22,7 +22,7 @@ jobs: - name: Build and export uses: docker/build-push-action@v6 with: - tags: gearbox:latest + tags: ghcr.io/decatur-robotics/gearbox:latest outputs: type=docker,dest=/tmp/gearbox.tar - name: Upload artifact From 730c7588db921a72cb129895c542cb53545155f3 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Thu, 14 Nov 2024 21:50:08 -0500 Subject: [PATCH 11/33] Add step to sign in to GHCR before pushing the Docker image --- .github/workflows/cicd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index d1bb8306..cda1f03a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -69,5 +69,8 @@ jobs: docker load --input /tmp/gearbox.tar docker image ls -a + - name: Sign in to GHCR + run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin + - name: Push to GHCR run: docker push ghcr.io/decatur-robotics/gearbox:latest \ No newline at end of file From 881f8d1bf8a8669ac15b82be7926ad75669a8a0a Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Fri, 15 Nov 2024 08:54:29 -0500 Subject: [PATCH 12/33] No more using cache spam --- lib/TheBlueAlliance.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/TheBlueAlliance.ts b/lib/TheBlueAlliance.ts index f05674d8..80fd1464 100644 --- a/lib/TheBlueAlliance.ts +++ b/lib/TheBlueAlliance.ts @@ -312,7 +312,6 @@ export namespace TheBlueAlliance { async loadCompetitionPairings() { if (global?.compIdPairs) { - console.log("using cache..."); this.competitionPairings = global.compIdPairs; } else { console.log("Loading Pairings For Competition Searches..."); From b267398906422f201955c007259d096b57111c1e Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Fri, 15 Nov 2024 18:02:59 -0500 Subject: [PATCH 13/33] Moved cd into a seperate workflow --- .github/workflows/{cicd.yml => cd.yml} | 30 +++---------- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 25 deletions(-) rename .github/workflows/{cicd.yml => cd.yml} (74%) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cd.yml similarity index 74% rename from .github/workflows/cicd.yml rename to .github/workflows/cd.yml index cda1f03a..b93ce414 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cd.yml @@ -1,12 +1,10 @@ -name: CI/CD +name: CD on: - push: - branches: - - main - pull_request: - branches: - - main + workflow_call: + secrets: + GHCR_TOKEN: + required: true workflow_dispatch: # Allows manual triggering of the workflow jobs: @@ -31,29 +29,11 @@ jobs: name: gearbox path: /tmp/gearbox.tar - unit_test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20' - - - name: Install dependencies - run: npm install - - - name: Unit Tests - run: npm run test - push_to_ghcr: runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} needs: - build - - unit_test steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f03dd931 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and export + uses: docker/build-push-action@v6 + with: + tags: ghcr.io/decatur-robotics/gearbox:latest + outputs: type=docker,dest=/tmp/gearbox.tar + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: gearbox + path: /tmp/gearbox.tar + + unit_test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Unit Tests + run: npm run test + + deploy: + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + needs: + - build + - unit_test + uses: ./.github/workflows/cd.yml + secrets: + GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} \ No newline at end of file From eb59eeae331b177e4eff26130fb008a8e3823de2 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Fri, 15 Nov 2024 18:05:55 -0500 Subject: [PATCH 14/33] CI build no longer saves artifact --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f03dd931..7dc33118 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,12 +25,6 @@ jobs: tags: ghcr.io/decatur-robotics/gearbox:latest outputs: type=docker,dest=/tmp/gearbox.tar - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: gearbox - path: /tmp/gearbox.tar - unit_test: runs-on: ubuntu-latest steps: From a9be7725b91011a5f0449af17073e700206162de Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Fri, 15 Nov 2024 21:55:30 -0500 Subject: [PATCH 15/33] Reorganized workflows --- .github/workflows/ci.yml | 15 ++------------- .github/workflows/onpush.yml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/onpush.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dc33118..c2661830 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,10 @@ name: CI on: - push: - branches: - - main pull_request: branches: - main + workflow_call: workflow_dispatch: # Allows manual triggering of the workflow jobs: @@ -40,13 +38,4 @@ jobs: run: npm install - name: Unit Tests - run: npm run test - - deploy: - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - needs: - - build - - unit_test - uses: ./.github/workflows/cd.yml - secrets: - GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} \ No newline at end of file + run: npm run test \ No newline at end of file diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml new file mode 100644 index 00000000..bebe4848 --- /dev/null +++ b/.github/workflows/onpush.yml @@ -0,0 +1,18 @@ +name: On Push + +on: + push: + branches: + - main + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + ci: + uses: ./.github/workflows/ci.yml + + cd: + needs: + - ci + uses: ./.github/workflows/cd.yml + secrets: + GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} \ No newline at end of file From e6a31fd103f2fbec4ed64731cd001789b05c6606 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sat, 16 Nov 2024 14:14:00 -0500 Subject: [PATCH 16/33] Added write file step as a test --- .github/workflows/cd.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b93ce414..92f2ece2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -16,6 +16,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + + - name: Write file + uses: DamianReeves/write-file-action@master + with: + path: test.txt + contents: | + Hello World! + write-mode: overwrite - name: Build and export uses: docker/build-push-action@v6 From 3de3ce4bcc0ea361115c34af8d80ca6f1ef3b1e3 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sat, 16 Nov 2024 14:40:57 -0500 Subject: [PATCH 17/33] Reworked write file step in cd --- .github/workflows/cd.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 92f2ece2..9d442cf6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -18,12 +18,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Write file - uses: DamianReeves/write-file-action@master - with: - path: test.txt - contents: | - Hello World! - write-mode: overwrite + run: echo "test" > test.txt - name: Build and export uses: docker/build-push-action@v6 From 39be078231c8268c3f14575d584e29f07f723ab4 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sat, 16 Nov 2024 15:10:16 -0500 Subject: [PATCH 18/33] Add debug ls commands before and after writing file in CD workflow --- .github/workflows/cd.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9d442cf6..466ab957 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -17,8 +17,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: ls + run: ls + - name: Write file run: echo "test" > test.txt + + - name: ls + run: ls - name: Build and export uses: docker/build-push-action@v6 From 86c77c2b5ad08b45b782c4f406a5f6d520afc65d Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sat, 16 Nov 2024 16:48:18 -0500 Subject: [PATCH 19/33] Add context parameter to Docker build step in CD workflow --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 466ab957..346ecb0a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -31,6 +31,7 @@ jobs: with: tags: ghcr.io/decatur-robotics/gearbox:latest outputs: type=docker,dest=/tmp/gearbox.tar + context: . # Needed for Docker to find files made during the workflow - name: Upload artifact uses: actions/upload-artifact@v4 From 6075b69b88d197661c727d0ce07ef9981f1be0cc Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 15:44:34 -0500 Subject: [PATCH 20/33] CD no longer saves the artifact --- .github/workflows/cd.yml | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 346ecb0a..b1305d37 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: # Allows manual triggering of the workflow jobs: - build: + build_and_push: runs-on: ubuntu-latest steps: - name: Checkout @@ -17,14 +17,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: ls - run: ls - - name: Write file run: echo "test" > test.txt - - - name: ls - run: ls - name: Build and export uses: docker/build-push-action@v6 @@ -33,32 +27,6 @@ jobs: outputs: type=docker,dest=/tmp/gearbox.tar context: . # Needed for Docker to find files made during the workflow - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: gearbox - path: /tmp/gearbox.tar - - push_to_ghcr: - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - needs: - - build - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: gearbox - path: /tmp - - - name: Load image - run: | - docker load --input /tmp/gearbox.tar - docker image ls -a - - name: Sign in to GHCR run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin From 27a4ddb8dc6c56f8b36ab0798451882cfaa55cf5 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 15:47:20 -0500 Subject: [PATCH 21/33] Added environment to cd --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b1305d37..74a585d9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,6 +10,7 @@ on: jobs: build_and_push: runs-on: ubuntu-latest + environment: Test steps: - name: Checkout uses: actions/checkout@v4 From 9cf03a4ee4c73860722cb8fef22077cfb8d9e164 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 15:51:51 -0500 Subject: [PATCH 22/33] Add image loading step to CD workflow --- .github/workflows/cd.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 74a585d9..139d34e6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,7 +10,7 @@ on: jobs: build_and_push: runs-on: ubuntu-latest - environment: Test + environment: Test steps: - name: Checkout uses: actions/checkout@v4 @@ -27,6 +27,11 @@ jobs: tags: ghcr.io/decatur-robotics/gearbox:latest outputs: type=docker,dest=/tmp/gearbox.tar context: . # Needed for Docker to find files made during the workflow + + - name: Load image + run: | + docker load --input /tmp/gearbox.tar + docker image ls -a - name: Sign in to GHCR run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin From f387724eceb5fb2492f5ec656cb04d3b4563b6cd Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:15:32 -0500 Subject: [PATCH 23/33] Disabled build summary for CD Docker build --- .github/workflows/cd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 139d34e6..f4f720a5 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -23,6 +23,8 @@ jobs: - name: Build and export uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_SUMMARY: false with: tags: ghcr.io/decatur-robotics/gearbox:latest outputs: type=docker,dest=/tmp/gearbox.tar From a21d27851388f2666e70e4c8d7769140debf227c Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:20:54 -0500 Subject: [PATCH 24/33] Use only 1 set of SSL keys now --- .gitignore | 4 +++- index.ts | 10 +++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 658bc761..04cafac3 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,6 @@ next-env.d.ts /public/sw.js /public/sw.js.map /public/workbox-* -/public/fallback-* \ No newline at end of file +/public/fallback-* + +/certs/*.* \ No newline at end of file diff --git a/index.ts b/index.ts index 31b8429f..28bfe268 100644 --- a/index.ts +++ b/index.ts @@ -2,7 +2,7 @@ import { join } from "path"; import { createServer } from "https"; import { parse } from "url"; import next from "next"; -import fs from "fs"; +import fs, { readFileSync } from "fs"; import { App } from "@slack/bolt"; import SlackCommands from "./lib/SlackCommands"; import { IncomingMessage, ServerResponse, request } from "http"; @@ -18,12 +18,8 @@ const handle = app.getRequestHandler(); console.log("Constants set"); const httpsOptions = { - key: dev - ? fs.readFileSync("./certs/localhost-key.pem") - : fs.readFileSync("./certs/production-key.pem"), - cert: dev - ? fs.readFileSync("./certs/localhost.pem") - : fs.readFileSync("./certs/production.pem"), + key: readFileSync("./certs/key.pem"), + cert: readFileSync("./certs/cert.pem"), }; console.log("HTTPS options set"); From 5e48381c3622443fe9ca18f3c1fdcf1b3f451cbd Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:22:15 -0500 Subject: [PATCH 25/33] Remove unused SSL certificate and key files --- certs/localhost-key.pem | 28 ---------------------------- certs/localhost.pem | 28 ---------------------------- 2 files changed, 56 deletions(-) delete mode 100644 certs/localhost-key.pem delete mode 100644 certs/localhost.pem diff --git a/certs/localhost-key.pem b/certs/localhost-key.pem deleted file mode 100644 index e2a14c23..00000000 --- a/certs/localhost-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC8/fJcFm48w6xL -sEGy2YO+9E2Z6htJK6xrZjnNNjGCWgSIAA9ucdXlh2hU1SMwGHMMhMIBlN6cHJLP -giMCcanw8QSZysD0vqAayWX8KllxyDhu/x4CDDy+qlU/kJyb/h+wvdTmTdze4IJb -PEgRSvwfAI2Z+4Z8llH0tF5vumarNgcc3MhCYP+gNmU1LGlNQTmo4xUXNmK9Ykst -swoGtSm/4PBQwpOmK8t0WE/cYYBNZ6C3XRX0eCEfLrodVFIGMg0pCjeDngGKLfMv -dk3GVl/otsMUpCMeAkVC0ErI3iEAjIeyCMsoLPYILOhsAvY8KjB+j/JhJpZejwl4 -DqgbONU/AgMBAAECggEAN47n6o5lhdN4GSANkEhFZKNpFLAvqUj/fOsmXt9pmopf -/qMV5j/sw3cVAqtNltv5Jlr4tYJQFtCHkB0Psa48aSpRUey64LgRVQ6Tvpesh7h2 -bprs9Wknil2EhhU7FNiV9F058yI8pgCWEcAc54iFqY9+ESBSHtoJ6cgEYxAHEplj -uYfZFBe/zsOaHf9ohrJre+VRntUiHxrwGFzR03qHucdxFC9ns0NYIq+NoQErqzt3 -oqZP4WzDzjgEMNLag4+IXjCg/RowUoQa7BfhfsGcViizn9ypTgQV9iBlqdCCopN4 -ONNpy00dkFVgjApC8BQI5Wsk5KKPNP0ZTx4APp+yUQKBgQDMEdAZd9rkMKY6INCc -3oqtNSV+msdXs3vlNvjln1OGLqRmt1Os1xHfQF7f8+vt4f+wHJIZpSsM6bF+YTT9 -aWdQOGg4V4KWpNYPP/u54d50cbtmEYtJFAJMVNLfJ5yr4OqmIjiCK2WNahK2qv6t -xageCDeqeD8dtxAcs4KMOFAnAwKBgQDtFeXf7f2ru6EqLmigooyH2bMLOrrFJHYT -N7ENCkiJLIbv3bmvoTfoWWWDx2pf8psqYLn/NcDuU3fwfS2cOjk2a171SjOHbatD -vKErp9XgJZFiRDq4QLn/+CMNyicdiyDLUHaBZbZ3/EXRvr9BBG8Vmv3eFv44zMAV -ZgcwDHk2FQKBgGMAGUbhwI2HlH0Kwmn4BKr255O+HwtLBcYznxg27VxhcFxsf+mQ -BRmbrutS+JhVVafolHBgkrwW+4bmPcDay8Y9N0JuIepXWYnYbpTFIRi4vENOK5Zu -YJcLZ6nfG8C+wteKLoPn7cJnPWDlH9zJ0T+QmQDYiTYvQ1/JLoI8J5ZlAoGADVSu -4UF7gv2A2WNUpLufFUBrbdU2jUE4lmoKPYZ3f6cOS0x3VWXGQ/1K1PcQhyaYDPD1 -ZGE8YOo2k0Imn2MytlmhND+g2BuVhrCDi3Xbc8gI/bKCbrvM+ZSVPABC5Mle5a+3 -ih0S/noj3uBP1rMOH/PgFG3Mi5sPreRXwR7ibeUCgYAAsDA0v8igGWgjGijr/Umk -lw8QvBVO7H+xQMKkAgxhgGrXMdy2ctHm1c1CaU/2GUJKCjt7iLks3FbMkh8DC08E -SkRXe/Po21xVkN72kMnJFRCd6xfTYxWy7+SvIn/hW6NPLaemPrAdCLG/Oh/POoqs -PdeRarxK6Bm41Lj+rErheA== ------END PRIVATE KEY----- diff --git a/certs/localhost.pem b/certs/localhost.pem deleted file mode 100644 index 7a9fa993..00000000 --- a/certs/localhost.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIExzCCAy+gAwIBAgIRAJd3DtWZH47gx195IWiwQWcwDQYJKoZIhvcNAQELBQAw -ga0xHjAcBgNVBAoTFW1rY2VydCBkZXZlbG9wbWVudCBDQTFBMD8GA1UECww4TEFQ -VE9QLUxCNjFRUlJJXHJkZGVsQExBUFRPUC1MQjYxUVJSSSAoUmVuYXRvIERlbGwn -T3NzbykxSDBGBgNVBAMMP21rY2VydCBMQVBUT1AtTEI2MVFSUklccmRkZWxATEFQ -VE9QLUxCNjFRUlJJIChSZW5hdG8gRGVsbCdPc3NvKTAeFw0yNDA2MjUxNTUwMTFa -Fw0yNjA5MjUxNTUwMTFaMGwxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBj -ZXJ0aWZpY2F0ZTFBMD8GA1UECww4TEFQVE9QLUxCNjFRUlJJXHJkZGVsQExBUFRP -UC1MQjYxUVJSSSAoUmVuYXRvIERlbGwnT3NzbykwggEiMA0GCSqGSIb3DQEBAQUA -A4IBDwAwggEKAoIBAQC8/fJcFm48w6xLsEGy2YO+9E2Z6htJK6xrZjnNNjGCWgSI -AA9ucdXlh2hU1SMwGHMMhMIBlN6cHJLPgiMCcanw8QSZysD0vqAayWX8KllxyDhu -/x4CDDy+qlU/kJyb/h+wvdTmTdze4IJbPEgRSvwfAI2Z+4Z8llH0tF5vumarNgcc -3MhCYP+gNmU1LGlNQTmo4xUXNmK9YkstswoGtSm/4PBQwpOmK8t0WE/cYYBNZ6C3 -XRX0eCEfLrodVFIGMg0pCjeDngGKLfMvdk3GVl/otsMUpCMeAkVC0ErI3iEAjIey -CMsoLPYILOhsAvY8KjB+j/JhJpZejwl4DqgbONU/AgMBAAGjgaEwgZ4wDgYDVR0P -AQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB8GA1UdIwQYMBaAFGz0wy5u -D4tXwNY83ZwZFpugXK03MFYGA1UdEQRPME2CC2V4YW1wbGUuY29tgg0qLmV4YW1w -bGUuY29tggxleGFtcGxlLnRlc3SCCWxvY2FsaG9zdIcEfwAAAYcQAAAAAAAAAAAA -AAAAAAAAATANBgkqhkiG9w0BAQsFAAOCAYEA855figRKXfJtdKrJeVNfOg1ZYdyi -nizTaYgS7eezQrU5v7Jkx5JMNwwaxXOCu/JBkJpRMti1TdJ77oeekq2ZJCpej3Hy -bfXUryOY3Ijn4d4AwEMCIugjc20VDNsPiwsMBfnQPZ2kX03xGM0lvHPwtL8aE1wc -1VRsYfeJzdwY2mkk5H+qOKy6kGw0qNPsc3HLh06oH0J3Gti8a3fMM6xlgDXaBURS -qrnjdGPeLm3YWy/3+ae4ZsD54vAzIjS6rzda4ME7c62C/XXlaDh6P7DBsy01EnRi -KXPJ4bVNy9Q1GQNgFJjsFB8xjLlKYkmR9pxpSb2+PcF32T4Ft7sN0Xme1+fONxx9 -i+jQ1Fd/l+KXH5DpDJexHHNdjh6fd2SwnfeJh9jojcY6Nt2s7WJBiZQF5hHeDhHu -W74s9E3EoxpEFrui22KCgr8qzioFoMNvP2PJ6/D/QBAKpMCSRKuGWsBZPJbeNx5L -TacfmVgKIh8m/eL9gAs6LlGte0Upi4SpaesT ------END CERTIFICATE----- From 00bf2f7f907c2da6c6ce14addf8a085fd5037e32 Mon Sep 17 00:00:00 2001 From: Renato Dell'Osso Date: Sun, 17 Nov 2024 16:30:47 -0500 Subject: [PATCH 26/33] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c90b8425..fb95b66c 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,8 @@ Features full feature parity with SJ2, whilst remaining simpler, faster and cool - NPM - A MongoDB instance - We use Atlas -- An SSL certificate saved as `localhost-key.pem` and `localhost.pem` +- An SSL certificate saved as `certs/key.pem` and `certs/cert.pem` - Can be generated with OpenSSL -- An SSL certificate saved as `production-key.pem` and `production.pem` - - This can be the same as the development certificate above - Secrets: - A Blue Alliance API key - An Orange Alliance API key @@ -67,4 +65,4 @@ We recommend you start with issues labelled `good first issue` to get a feel for Made with [contrib.rocks](https://contrib.rocks). ## Licensed under a CC BY-NC-SA 4.0 license -Read the license [here](LICENSE.md). \ No newline at end of file +Read the license [here](LICENSE.md). From b423436d14b597d5f10eac5db6b886dd778fffce Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:40:14 -0500 Subject: [PATCH 27/33] Add TEST_SECRET to CD workflows for secure file writing --- .github/workflows/cd.yml | 4 +++- .github/workflows/onpush.yml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f4f720a5..e8013b9d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,8 @@ on: secrets: GHCR_TOKEN: required: true + TEST_SECRET: + required: true workflow_dispatch: # Allows manual triggering of the workflow jobs: @@ -19,7 +21,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Write file - run: echo "test" > test.txt + run: echo "${{ secrets.TEST_SECRET }}" > test.txt - name: Build and export uses: docker/build-push-action@v6 diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index bebe4848..7e3a4a29 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -15,4 +15,5 @@ jobs: - ci uses: ./.github/workflows/cd.yml secrets: - GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} \ No newline at end of file + GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} + TEST_SECRET: ${{ secrets.TEST_SECRET }} \ No newline at end of file From ff9e5106238c7f81c01d16332614769199cabc6b Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:45:23 -0500 Subject: [PATCH 28/33] Switch GHCR_TOKEN to GITHUB_TOKEN --- .github/workflows/cd.yml | 4 ++-- .github/workflows/onpush.yml | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e8013b9d..697f0a56 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -3,7 +3,7 @@ name: CD on: workflow_call: secrets: - GHCR_TOKEN: + GITHUB_TOKEN: required: true TEST_SECRET: required: true @@ -38,7 +38,7 @@ jobs: docker image ls -a - name: Sign in to GHCR - run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin - name: Push to GHCR run: docker push ghcr.io/decatur-robotics/gearbox:latest \ No newline at end of file diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index 7e3a4a29..404387b9 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -6,6 +6,9 @@ on: - main workflow_dispatch: # Allows manual triggering of the workflow +permissions: + packages: write + jobs: ci: uses: ./.github/workflows/ci.yml @@ -15,5 +18,5 @@ jobs: - ci uses: ./.github/workflows/cd.yml secrets: - GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TEST_SECRET: ${{ secrets.TEST_SECRET }} \ No newline at end of file From 835718f688caf419a3b1b72a88564d6147350262 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:46:53 -0500 Subject: [PATCH 29/33] Update workflow permissions and streamline secret usage in CI/CD configurations --- .github/workflows/cd.yml | 5 +++-- .github/workflows/onpush.yml | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 697f0a56..9d2a52a9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -3,12 +3,13 @@ name: CD on: workflow_call: secrets: - GITHUB_TOKEN: - required: true TEST_SECRET: required: true workflow_dispatch: # Allows manual triggering of the workflow +permissions: + packages: write + jobs: build_and_push: runs-on: ubuntu-latest diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index 404387b9..0ae3cb5f 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -6,9 +6,6 @@ on: - main workflow_dispatch: # Allows manual triggering of the workflow -permissions: - packages: write - jobs: ci: uses: ./.github/workflows/ci.yml @@ -18,5 +15,4 @@ jobs: - ci uses: ./.github/workflows/cd.yml secrets: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TEST_SECRET: ${{ secrets.TEST_SECRET }} \ No newline at end of file From 49a1b26a5a64a8d79c151621387174d05ae689e9 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:54:23 -0500 Subject: [PATCH 30/33] Update CD workflows to include SSL key, SSL cert, and environment file secrets --- .github/workflows/cd.yml | 16 +++++++++++++--- .github/workflows/onpush.yml | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9d2a52a9..eaae860e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -3,7 +3,11 @@ name: CD on: workflow_call: secrets: - TEST_SECRET: + SSL_KEY: + required: true + SSL_CERT: + required: true + ENV_FILE: required: true workflow_dispatch: # Allows manual triggering of the workflow @@ -21,8 +25,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Write file - run: echo "${{ secrets.TEST_SECRET }}" > test.txt + - name: Write ENV file + run: echo "${{ secrets.ENV_FILE }}" > .env + + - name: Write SSL key + run: echo "${{ secrets.SSL_KEY }}" > certs/ssl.key + + - name: Write SSL cert + run: echo "${{ secrets.SSL_CERT }}" > certs/ssl.cert - name: Build and export uses: docker/build-push-action@v6 diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index 0ae3cb5f..16929e5a 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -15,4 +15,6 @@ jobs: - ci uses: ./.github/workflows/cd.yml secrets: - TEST_SECRET: ${{ secrets.TEST_SECRET }} \ No newline at end of file + SSL_KEY: ${{ secrets.SSL_KEY }} + SSL_CERT: ${{ secrets.SSL_CERT }} + ENV_FILE: ${{ secrets.ENV_FILE }} \ No newline at end of file From a14f4b916f2824f9005f097d988f43b82f76ffa5 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 17 Nov 2024 16:59:53 -0500 Subject: [PATCH 31/33] Added mkdir to cd --- .github/workflows/cd.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index eaae860e..7a95a143 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -25,14 +25,17 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Write ENV file - run: echo "${{ secrets.ENV_FILE }}" > .env + - name: Create certs directory + run: mkdir certs - name: Write SSL key run: echo "${{ secrets.SSL_KEY }}" > certs/ssl.key - name: Write SSL cert run: echo "${{ secrets.SSL_CERT }}" > certs/ssl.cert + + - name: Write ENV file + run: echo "${{ secrets.ENV_FILE }}" > .env - name: Build and export uses: docker/build-push-action@v6 From a6eb730e2a9d5db6c40169dce89868cd35bd3ad7 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Mon, 18 Nov 2024 09:28:06 -0500 Subject: [PATCH 32/33] Fixed team creation --- pages/createTeam.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pages/createTeam.tsx b/pages/createTeam.tsx index 03f9aec8..9b8f882a 100644 --- a/pages/createTeam.tsx +++ b/pages/createTeam.tsx @@ -39,12 +39,7 @@ export default function CreateTeam() { } const findResult = await api.findTeamByNumberAndLeague(Number(team?.number), team.league); - if (!findResult) { - setError("Failed to check if team already exists. Please try again later."); - return; - } - - if (findResult._id) { + if (findResult?._id) { setError("This Team Already Exists"); return; } From 066f620aaa55026f5502a1567dd9bffc32aff819 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Mon, 18 Nov 2024 21:06:16 -0500 Subject: [PATCH 33/33] Disabled Slack app --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 28bfe268..cfbb62be 100644 --- a/index.ts +++ b/index.ts @@ -24,7 +24,7 @@ const httpsOptions = { console.log("HTTPS options set"); -startSlackApp(); +// startSlackApp(); console.log("App preparing..."); app.prepare().then(() => {