Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .github/workflows/bot_cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_dispatch:
push:
paths:
- "apps/bot/**"
branches:
- main

jobs:
deploy:
runs-on: depot-ubuntu-24.04-8
timeout-minutes: 60
concurrency: bot-fly-deploy
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --config apps/bot/fly.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/bot_ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- apps/bot/**
jobs:
ci:
runs-on: depot-ubuntu-24.04-8
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm -F @hypr/bot typecheck
- run: pnpm -F @hypr/bot test
12 changes: 12 additions & 0 deletions apps/bot/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**/node_modules/
**/.git
**/README.md
**/LICENSE
**/.vscode
**/npm-debug.log
**/coverage
**/.env
**/.editorconfig
**/dist
**/*.pem
Dockerfile
7 changes: 7 additions & 0 deletions apps/bot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
npm-debug.log
*.pem
!mock-cert.pem
.env
coverage
lib
25 changes: 25 additions & 0 deletions apps/bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://pnpm.io/docker#example-3-build-on-cicd
FROM node:22-slim AS node-base
WORKDIR /repo

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV CI=true
RUN corepack enable

FROM node-base AS deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY apps/bot/package.json apps/bot/package.json
RUN pnpm fetch --filter @hypr/bot

FROM deps AS build
COPY apps/bot apps/bot
RUN pnpm install --filter @hypr/bot --frozen-lockfile
RUN pnpm --filter @hypr/bot run build
RUN pnpm deploy --filter @hypr/bot --prod --legacy /runtime

FROM node:22-slim AS runtime
WORKDIR /app
ENV NODE_ENV="production"
COPY --from=build /runtime ./
CMD ["node", "node_modules/probot/bin/probot.js", "run", "./lib/index.js"]
137 changes: 137 additions & 0 deletions apps/bot/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# This is a GitHub App Manifest. These settings will be used by default when
# initially configuring your GitHub App.
#
# NOTE: changing this file will not update your GitHub App settings.
# You must visit github.com/settings/apps/your-app-name to edit them.
#
# Read more about configuring your GitHub App:
# https://probot.github.io/docs/development/#configuring-a-github-app
#
# Read more about GitHub App Manifests:
# https://developer.github.com/apps/building-github-apps/creating-github-apps-from-a-manifest/

# The list of events the GitHub App subscribes to.
# Uncomment the event names below to enable them.
default_events:
# - check_run
# - check_suite
# - commit_comment
# - create
# - delete
# - deployment
# - deployment_status
# - fork
# - gollum
# - issue_comment
- issues
# - label
# - milestone
# - member
# - membership
# - org_block
# - organization
# - page_build
# - project
# - project_card
# - project_column
# - public
# - pull_request
# - pull_request_review
# - pull_request_review_comment
# - push
# - release
# - repository
# - repository_import
# - status
# - team
# - team_add
# - watch

# The set of permissions needed by the GitHub App. The format of the object uses
# the permission name for the key (for example, issues) and the access type for
# the value (for example, write).
# Valid values are `read`, `write`, and `none`
default_permissions:
# Repository creation, deletion, settings, teams, and collaborators.
# https://developer.github.com/v3/apps/permissions/#permission-on-administration
# administration: read

# Checks on code.
# https://developer.github.com/v3/apps/permissions/#permission-on-checks
# checks: read

# Repository contents, commits, branches, downloads, releases, and merges.
# https://developer.github.com/v3/apps/permissions/#permission-on-contents
# contents: read

# Deployments and deployment statuses.
# https://developer.github.com/v3/apps/permissions/#permission-on-deployments
# deployments: read

# Issues and related comments, assignees, labels, and milestones.
# https://developer.github.com/v3/apps/permissions/#permission-on-issues
issues: write

# Search repositories, list collaborators, and access repository metadata.
# https://developer.github.com/v3/apps/permissions/#metadata-permissions
metadata: read

# Retrieve Pages statuses, configuration, and builds, as well as create new builds.
# https://developer.github.com/v3/apps/permissions/#permission-on-pages
# pages: read

# Pull requests and related comments, assignees, labels, milestones, and merges.
# https://developer.github.com/v3/apps/permissions/#permission-on-pull-requests
# pull_requests: read

# Manage the post-receive hooks for a repository.
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
# repository_hooks: read

# Manage repository projects, columns, and cards.
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-projects
# repository_projects: read

# Retrieve security vulnerability alerts.
# https://developer.github.com/v4/object/repositoryvulnerabilityalert/
# vulnerability_alerts: read

# Commit statuses.
# https://developer.github.com/v3/apps/permissions/#permission-on-statuses
# statuses: read

# Organization members and teams.
# https://developer.github.com/v3/apps/permissions/#permission-on-members
# members: read

# View and manage users blocked by the organization.
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-user-blocking
# organization_user_blocking: read

# Manage organization projects, columns, and cards.
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-projects
# organization_projects: read

# Manage team discussions and related comments.
# https://developer.github.com/v3/apps/permissions/#permission-on-team-discussions
# team_discussions: read

# Manage the post-receive hooks for an organization.
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-hooks
# organization_hooks: read

# Get notified of, and update, content references.
# https://developer.github.com/v3/apps/permissions/
# organization_administration: read
# The name of the GitHub App. Defaults to the name specified in package.json
# name: My Probot App

# The homepage of your GitHub App.
# url: https://example.com/

# A description of the GitHub App.
# description: A description of my awesome app

# Set to true when your GitHub App is available to the public or false when it is only accessible to the owner of the app.
# Default: true
# public: false
38 changes: 38 additions & 0 deletions apps/bot/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# fly.toml app configuration file generated for hyprnote-bot on 2025-11-30T18:55:28+09:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'hyprnote-bot'
primary_region = 'sjc'

[build]
dockerfile = "Dockerfile"

[deploy]
strategy = 'bluegreen'

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 1
processes = ['app']

[http_service.concurrency]
type = 'connections'
hard_limit = 25
soft_limit = 20

[[http_service.checks]]
interval = '10s'
timeout = '2s'
grace_period = '5s'
method = 'get'
path = '/health'

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
28 changes: 28 additions & 0 deletions apps/bot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@hypr/bot",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"start": "probot run ./lib/index.js",
"test": "vitest run"
},
"dependencies": {
"probot": "^13.4.5"
},
"devDependencies": {
"@types/node": "^20.0.0",
"nock": "^14.0.5",
"smee-client": "^2.0.0",
"vitest": "^2.0.0",
"typescript": "^5.8.3"
},
"overrides": {
"@types/pg": "8.15.1"
},
"engines": {
"node": ">= 18"
},
"type": "module"
}
18 changes: 18 additions & 0 deletions apps/bot/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ApplicationFunctionOptions, Probot } from "probot";

export default (app: Probot, { getRouter }: ApplicationFunctionOptions) => {
if (getRouter) {
const router = getRouter("/");

router.get("/health", (_req, res) => {
res.send("OK");
});
}

app.on("issues.opened", async (context) => {
const issueComment = context.issue({
body: "Thanks for opening this issue!",
});
await context.octokit.issues.createComment(issueComment);
});
};
18 changes: 18 additions & 0 deletions apps/bot/test/fixtures/issues.opened.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"action": "opened",
"issue": {
"number": 1,
"user": {
"login": "hiimbex"
}
},
"repository": {
"name": "testing-things",
"owner": {
"login": "hiimbex"
}
},
"installation": {
"id": 2
}
}
27 changes: 27 additions & 0 deletions apps/bot/test/fixtures/mock-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAli7V49NdZe+XYC1pLaHM0te8kiDmZBJ1u2HJHN8GdbROB6NO
VpC3xK7NxQn6xpvZ9ux20NvcDvGle+DOptZztBH+np6h2jZQ1/kD1yG1eQvVH4th
/9oqHuIjmIfO8lIe4Hyd5Fw5xHkGqVETTGR+0c7kdZIlHmkOregUGtMYZRUi4YG+
q0w+uFemiHpGKXbeCIAvkq7aIkisEzvPWfSyYdA6WJHpxFk7tD7D8VkzABLVRHCq
AuyqPG39BhGZcGLXx5rGK56kDBJkyTR1t3DkHpwX+JKNG5UYNwOG4LcQj1fteeta
TdkYUMjIyWbanlMYyC+dq7B5fe7el99jXQ1gXwIDAQABAoIBADKfiPOpzKLOtzzx
MbHzB0LO+75aHq7+1faayJrVxqyoYWELuB1P3NIMhknzyjdmU3t7S7WtVqkm5Twz
lBUC1q+NHUHEgRQ4GNokExpSP4SU63sdlaQTmv0cBxmkNarS6ZuMBgDy4XoLvaYX
MSUf/uukDLhg0ehFS3BteVFtdJyllhDdTenF1Nb1rAeN4egt8XLsE5NQDr1szFEG
xH5lb+8EDtzgsGpeIddWR64xP0lDIKSZWst/toYKWiwjaY9uZCfAhvYQ1RsO7L/t
sERmpYgh+rAZUh/Lr98EI8BPSPhzFcSHmtqzzejvC5zrZPHcUimz0CGA3YBiLoJX
V1OrxmECgYEAxkd8gpmVP+LEWB3lqpSvJaXcGkbzcDb9m0OPzHUAJDZtiIIf0UmO
nvL68/mzbCHSj+yFjZeG1rsrAVrOzrfDCuXjAv+JkEtEx0DIevU1u60lGnevOeky
r8Be7pmymFB9/gzQAd5ezIlTv/COgoO986a3h1yfhzrrzbqSiivw308CgYEAwecI
aZZwqH3GifR+0+Z1B48cezA5tC8LZt5yObGzUfxKTWy30d7lxe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