{"id":15479822,"url":"https://github.com/gr2m/cloudflare-worker-github-app-example","last_synced_at":"2025-10-14T22:07:06.518Z","repository":{"id":66069552,"uuid":"322390254","full_name":"gr2m/cloudflare-worker-github-app-example","owner":"gr2m","description":"A Cloudflare Worker + GitHub App Example","archived":false,"fork":false,"pushed_at":"2022-09-23T19:37:47.000Z","size":518,"stargazers_count":39,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-26T00:41:02.255Z","etag":null,"topics":["cloudflare-worker","cloudflare-workers"],"latest_commit_sha":null,"homepage":"https://github.com/apps/cloudflare-worker-example","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gr2m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"gr2m"}},"created_at":"2020-12-17T19:18:25.000Z","updated_at":"2025-05-30T17:04:18.000Z","dependencies_parsed_at":"2023-06-15T13:15:49.031Z","dependency_job_id":null,"html_url":"https://github.com/gr2m/cloudflare-worker-github-app-example","commit_stats":{"total_commits":23,"total_committers":3,"mean_commits":7.666666666666667,"dds":"0.17391304347826086","last_synced_commit":"5a0d0bec9c096f5a922acbbaa9fe2da882093985"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/gr2m/cloudflare-worker-github-app-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-app-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-app-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-app-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-app-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr2m","download_url":"https://codeload.github.com/gr2m/cloudflare-worker-github-app-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-app-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021744,"owners_count":26087053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-worker","cloudflare-workers"],"created_at":"2024-10-02T04:27:32.369Z","updated_at":"2025-10-14T22:07:06.501Z","avatar_url":"https://github.com/gr2m.png","language":"JavaScript","funding_links":["https://github.com/sponsors/gr2m"],"categories":[],"sub_categories":[],"readme":"# cloudflare-worker-github-app-example\n\n\u003e A Cloudflare Worker + GitHub App Example\n\nThe [worker.js](worker.js) file is a [Cloudflare Worker](https://workers.cloudflare.com/) which is continuously deployed using GitHub Actions (see [.github/workflows/deploy.yml](.github/workflows/deploy.yml)).\n\nThe worker does 2 things\n\n1. `GET` requests: respond with an HTML website with links and a live counter of installations.\n2. `POST` requests: handle webhook request from GitHub\n\n⚠️ The requests from GitHub are currently not verified using the signature, because [the code is currently using Node's crypto package](https://github.com/octokit/webhooks.js/blob/0e03e470034ac769a28ed37acb524b94e304bf96/src/sign/index.ts#L1). This will be resolved once I create a universal webhook verification package, similar to [`universal-github-app-jwt`](https://github.com/gr2m/universal-github-app-jwt/#readme). For the time being, you could define a secret path that that webhook requests by GitHub are sent to, in order to prevent anyone who knows your workers URL from sending fake webhook requests. See [#1](https://github.com/gr2m/cloudflare-worker-github-app-example/issues/1)\n\n![screen recording of GitHub app creating a comment on a new GitHub issue](assets/hello-there-cloudflare-worker.gif)\n\n## Step-by-step instructions to create your own\n\nNote that you require access to the new GitHub Actions for the automated deployment to work.\n\n1. Fork this repository\n1. [Create a GitHub App](https://developer.github.com/apps/building-github-apps/creating-a-github-app/)\n1. [Create a Cloudflare account](https://dash.cloudflare.com/) (it's free!) if you don't have one yet.\n1. Install the `wrangler` CLI and login with your account\n\n   ```\n   npm install --global wrangler\n   wrangler login\n   ```\n\n1. Edit the `wrangler.toml` file, change the value for `account_id` to your own ([select your account](https://dash.cloudflare.com/), then find your Account ID at the bottom of the side bar)\n1. Add the following secrets to your Cloudflare worker:\n\n   - `APP_ID`: In your GitHub App registration's settings page, find `App ID`\n\n     ```\n     wrangler secret put APP_ID\n     ```\n\n   - `WEBHOOK_SECRET`: In your GitHub App registration's settings page, find `Webhook secret`\n\n     ```\n     wrangler secret put WEBHOOK_SECRET\n     ```\n\n   - `PRIVATE_KEY`: Generate a private key (see the button at the bottom of your GitHub App registration's settings page).\n\n     1. You will be prompted to download a `*.pem` file. After download, rename it to `private-key.pem`.\n     1. Convert the key from the `PKCS#1` format to `PKCS#8` (The WebCrypto API only supports `PKCS#8`):\n\n        ```\n        openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in private-key.pem -out private-key-pkcs8.pem\n        ```\n\n     1. Write the contents of the new file into the secret `PRIVATE_KEY`:\n\n        ```\n        cat private-key-pkcs8.pem | wrangler secret put PRIVATE_KEY\n        ```\n\n1. Add the following secret in your fork's repository settings:\n   - `CF_API_TOKEN`: [Create a new token](https://dash.cloudflare.com/profile/api-tokens), use the \"Edit Cloudflare Workers\" template\n\nThat should be it. The `worker.js` file will now be continously deployed to Cloudflare each time there is a commit to master.\n\n## See also\n\n- [Cloudflare Worker GitHub OAuth Example](https://github.com/gr2m/cloudflare-worker-github-oauth-login/#readme)\n\n## Credits\n\nThe OAuth App Avatar and this repository's social preview are using [@cameronmcefee](https://github.com/cameronmcefee)'s [cloud](https://octodex.github.com/cloud/) Octodex graphic :octocat:💖\n\n## License\n\n[ISC](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fcloudflare-worker-github-app-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr2m%2Fcloudflare-worker-github-app-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fcloudflare-worker-github-app-example/lists"}