Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jill64/octoflare
🌤️ A framework for building GitHub Apps with Cloudflare Worker
https://github.com/jill64/octoflare
actions cloudflare framework github worker
Last synced: 5 days ago
JSON representation
🌤️ A framework for building GitHub Apps with Cloudflare Worker
- Host: GitHub
- URL: https://github.com/jill64/octoflare
- Owner: jill64
- License: mit
- Created: 2023-10-06T21:59:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T10:47:12.000Z (about 1 month ago)
- Last Synced: 2024-10-18T00:01:18.037Z (29 days ago)
- Topics: actions, cloudflare, framework, github, worker
- Language: TypeScript
- Homepage: https://npmjs.com/package/octoflare
- Size: 2.39 MB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# octoflare
🌤️ A framework for building GitHub Apps with Cloudflare Worker
[Example Apps](https://github.com/jill64?tab=repositories&q=github-app&type=&language=&sort=stargazers)
![workflow](./docs/workflow.png)
## Start New Project with CLI
```sh
npm create octoflare
```## Setup
The following must be set as environment variables for Cloudflare Workers
| Key | Value | Recommend Encryption | Auto Set by CLI |
| --------------------------- | ------------------------------------------------ | -------------------- | --------------- |
| OCTOFLARE_APP_ID | GitHub App ID | | |
| OCTOFLARE_PRIVATE_KEY_PKCS8 | GitHub App private key converted to PKCS8 format | ✔︎ | |
| OCTOFLARE_WEBHOOK_SECRET | GitHub App Webhook Secret | ✔︎ | |
| OCTOFLARE_APP_REPO | GitHub App Repository Name | | ✔︎ |
| OCTOFLARE_APP_OWNER | GitHub App Repository Owner Name | | ✔︎ |## Convert Privatekey
Before using the private key provided by GitHub, you need to convert it to PKCS8 format with the command below.
```sh
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in private-key.pem -out private-key-pkcs8.key
```or Using [Web Tool](https://decoder.link/rsa_converter)
## Commands
| npm script | Description |
| ---------------------- | ---------------------------------- |
| `npm run lint` | Lint |
| `npm run format` | Format by Prettier |
| `npm run build` | Build worker script |
| `npm run deploy` | Deploy worker script to cloudflare |
| `npm run build:action` | Build GitHub javascript action |## Example
### Worker
```js
// src/index.js
import { octoflare } from 'octoflare'export default octoflare(
async ({ request, env, app, payload, installation }) => {
// Application Code// Create Status Check for Target SHA
const { dispatchWorkflow } = await installation.createCheckRun({
repo: 'repository-name',
owner: 'repository-owner',
name: 'workflow-name',
head_sha: 'target-sha'
})await dispatchWorkflow({
// ...
})return new Response('Workflow Dispatched', {
status: 200
})
}
)
```[Handler Type Definition](./packages/octoflare/src/types/OctoflareHandler.ts)
### Action
```js
// action/src/index.js
import { action } from 'octoflare'action(({ request, env, app, payload }) => {
// Application Code// Return Checks Status
return {
conclusion: 'success',
output: {
title: 'Check Success',
summary: 'The check conclude as success'
}
}
})
```## License
[MIT](LICENSE)