Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
881f8d1
No more using cache spam
renatodellosso Nov 15, 2024
b267398
Moved cd into a seperate workflow
renatodellosso Nov 15, 2024
eb59eea
CI build no longer saves artifact
renatodellosso Nov 15, 2024
a9be772
Reorganized workflows
renatodellosso Nov 16, 2024
e6a31fd
Added write file step as a test
renatodellosso Nov 16, 2024
3de3ce4
Reworked write file step in cd
renatodellosso Nov 16, 2024
39be078
Add debug ls commands before and after writing file in CD workflow
renatodellosso Nov 16, 2024
86c77c2
Add context parameter to Docker build step in CD workflow
renatodellosso Nov 16, 2024
6075b69
CD no longer saves the artifact
renatodellosso Nov 17, 2024
27a4ddb
Added environment to cd
renatodellosso Nov 17, 2024
9cf03a4
Add image loading step to CD workflow
renatodellosso Nov 17, 2024
f387724
Disabled build summary for CD Docker build
renatodellosso Nov 17, 2024
a21d278
Use only 1 set of SSL keys now
renatodellosso Nov 17, 2024
5e48381
Remove unused SSL certificate and key files
renatodellosso Nov 17, 2024
00bf2f7
Update README.md
renatodellosso Nov 17, 2024
b423436
Add TEST_SECRET to CD workflows for secure file writing
renatodellosso Nov 17, 2024
01d6ad9
Merge branch 'main' of github.com:Decatur-Robotics/Gearbox
renatodellosso Nov 17, 2024
ff9e510
Switch GHCR_TOKEN to GITHUB_TOKEN
renatodellosso Nov 17, 2024
835718f
Update workflow permissions and streamline secret usage in CI/CD conf…
renatodellosso Nov 17, 2024
49a1b26
Update CD workflows to include SSL key, SSL cert, and environment fil…
renatodellosso Nov 17, 2024
a14f4b9
Added mkdir to cd
renatodellosso Nov 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CD

on:
workflow_call:
secrets:
SSL_KEY:
required: true
SSL_CERT:
required: true
ENV_FILE:
required: true
workflow_dispatch: # Allows manual triggering of the workflow

permissions:
packages: write

jobs:
build_and_push:
runs-on: ubuntu-latest
environment: Test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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
env:
DOCKER_BUILD_SUMMARY: false
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: Load image
run: |
docker load --input /tmp/gearbox.tar
docker image ls -a

- name: Sign in to GHCR
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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
pull_request:
branches:
- main
workflow_call:
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

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
76 changes: 0 additions & 76 deletions .github/workflows/cicd.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/onpush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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:
SSL_KEY: ${{ secrets.SSL_KEY }}
SSL_CERT: ${{ secrets.SSL_CERT }}
ENV_FILE: ${{ secrets.ENV_FILE }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ next-env.d.ts
/public/sw.js
/public/sw.js.map
/public/workbox-*
/public/fallback-*
/public/fallback-*

/certs/*.*
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
Read the license [here](LICENSE.md).
28 changes: 0 additions & 28 deletions certs/localhost-key.pem

This file was deleted.

28 changes: 0 additions & 28 deletions certs/localhost.pem

This file was deleted.

10 changes: 3 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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");
Expand Down
1 change: 0 additions & 1 deletion lib/TheBlueAlliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down