Skip to content

Commit

Permalink
workflow updates and pipeline prep
Browse files Browse the repository at this point in the history
  • Loading branch information
jprusik committed Nov 14, 2023
1 parent 0f2dda3 commit 6ca9000
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 51 deletions.
39 changes: 13 additions & 26 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<!-- Choose those applicable and remove the others. -->

- 🐛 Bug fix
- 🚀 New feature development
- 🧹 Tech debt (refactoring, code cleanup, dependency upgrades, etc.)
- 🤖 Build/deploy pipeline (DevOps)
- 🎂 Other
- [ ] 🐛 Bug fix
- [ ] 🚀 New feature development
- [ ] 🧹 Tech debt (refactoring, code cleanup, dependency upgrades, etc.)
- [ ] 🤖 Build/deploy pipeline (DevOps)
- [ ] 🎂 Other

## 📔 Objective

Expand All @@ -21,31 +21,18 @@
<!-- Explain the changes you've made to each file or major component. This should help the reviewer understand your changes. -->
<!-- Also refer to any related changes or PRs in other repositories. -->

- **file.ext:** Description of what was changed and why.
- **file.ext:** Description of what was changed and why.

## 📸 Screenshots

<!-- Required for any UI changes; delete if not applicable. Use fixed width images for better display. -->

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation or informed the documentation team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire! -->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes
- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation or informed the documentation team
12 changes: 1 addition & 11 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
"schedule:weekends",
":separateMajorReleases"
],
"enabledManagers": ["cargo", "github-actions", "npm", "nuget"],
"enabledManagers": ["github-actions", "npm"],
"packageRules": [
{
"groupName": "cargo minor",
"matchManagers": ["cargo"],
"matchUpdateTypes": ["minor", "patch"]
},
{
"groupName": "gh minor",
"matchManagers": ["github-actions"],
Expand All @@ -27,11 +22,6 @@
"groupName": "npm minor",
"matchManagers": ["npm"],
"matchUpdateTypes": ["minor", "patch"]
},
{
"groupName": "nuget minor",
"matchManagers": ["nuget"],
"matchUpdateTypes": ["minor", "patch"]
}
]
}
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Build API/client files

on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
paths-ignore:
- ".github/workflows/**"
push:
branches: [ "main" ]
paths-ignore:
- ".github/workflows/**"

defaults:
run:
shell: bash

jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: "18"

- name: Clean install dependencies and build
run: |
npm ci
npm run build
- name: Upload build as artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always()
with:
name: build-files
path: |
./api/build
./client/build
19 changes: 19 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Docker Image

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Build the Docker image
run: docker build . -f Dockerfile -t test-the-web:$(date +%s)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ WORKDIR /usr/app
COPY --from=build /usr/app/client/build ./client/build
COPY --from=build /usr/app/api/build ./api/build
COPY --from=build /usr/app/api/node_modules ./api/node_modules
COPY --from=build /usr/app/api/.env ./.env
COPY --from=build /usr/app/api/.en[v] ./
CMD ["node", "api/build/app.js"]
7 changes: 3 additions & 4 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ WORKDIR /usr/app
COPY . .
RUN npm ci
RUN npm run build
# CMD ["sh", "scripts/generate-certs.sh"]

FROM node:${NODE_VERSION}-alpine
WORKDIR /usr/app
COPY --from=build /usr/app/client/build ./client/build
COPY --from=build /usr/app/api/build ./api/build
COPY --from=build /usr/app/api/node_modules ./api/node_modules
COPY --from=build /usr/app/api/ssl.crt ./api/ssl.crt
COPY --from=build /usr/app/api/ssl.key ./api/ssl.key
COPY --from=build /usr/app/api/.env ./.env
COPY --from=build /usr/app/api/ssl.cr[t] ./api/
COPY --from=build /usr/app/api/ssl.ke[y] ./api/
COPY --from=build /usr/app/api/.en[v] ./
CMD ["node", "api/build/app.js"]
21 changes: 12 additions & 9 deletions api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const staticFilesPath = process.env.STATIC_FILES_DIR || "client/build";
const app = express();

if (staticFilesPath) {
app.use(express.static(`${__dirname}/../../${process.env.STATIC_FILES_DIR}`));
app.use(express.static(`${__dirname}/../../${staticFilesPath}`));
} else {
console.warn("The static files folder could not be found.");
}
Expand All @@ -35,12 +35,15 @@ app.use(
},
);

function handlePost(request: Request, response: Response, route: string) {
console.log("POST received for:", route);
function handleRequest(request: Request, response: Response, route: string) {
console.log(`${request.method} received for:`, route);

const referrerURL = request.get("Referrer") || "";
let referrerQueryParams = "";

const isLogin = route === ROUTES.LOGIN;

// @TODO enable fail case
const responsePath = `/forms/response/${
isLogin ? "login-success" : "request-success"
}`;
Expand All @@ -62,21 +65,21 @@ function handlePost(request: Request, response: Response, route: string) {
}

app
.route(ROUTES.LOGIN)
.route(ROUTES.IDENTITY)
.post((request: Request, response: Response) =>
handlePost(request, response, ROUTES.LOGIN),
handleRequest(request, response, ROUTES.IDENTITY),
);

app
.route(ROUTES.PAYMENT)
.route(ROUTES.LOGIN)
.post((request: Request, response: Response) =>
handlePost(request, response, ROUTES.PAYMENT),
handleRequest(request, response, ROUTES.LOGIN),
);

app
.route(ROUTES.IDENTITY)
.route(ROUTES.PAYMENT)
.post((request: Request, response: Response) =>
handlePost(request, response, ROUTES.IDENTITY),
handleRequest(request, response, ROUTES.PAYMENT),
);

try {
Expand Down

0 comments on commit 6ca9000

Please sign in to comment.