Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/cloc-2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso authored Nov 19, 2024
2 parents 302e502 + 066f620 commit e9bb6ed
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 152 deletions.
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.

12 changes: 4 additions & 8 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,17 +18,13 @@ 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");

startSlackApp();
// startSlackApp();

console.log("App preparing...");
app.prepare().then(() => {
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
7 changes: 1 addition & 6 deletions pages/createTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e9bb6ed

Please sign in to comment.