{"id":26289974,"url":"https://github.com/slack-samples/deno-github-functions","last_synced_at":"2025-05-07T22:43:54.947Z","repository":{"id":114488845,"uuid":"525531731","full_name":"slack-samples/deno-github-functions","owner":"slack-samples","description":"A collection of functions that map to oft-used functionality on GitHub","archived":false,"fork":false,"pushed_at":"2025-01-16T18:56:51.000Z","size":449,"stargazers_count":40,"open_issues_count":1,"forks_count":13,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-31T15:00:04.555Z","etag":null,"topics":["next-gen"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slack-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-16T20:23:58.000Z","updated_at":"2025-03-08T14:06:51.000Z","dependencies_parsed_at":"2023-10-30T23:28:36.286Z","dependency_job_id":"83aa73ca-bdd6-4c84-bc58-8b137dd78d88","html_url":"https://github.com/slack-samples/deno-github-functions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"slack-samples/deno-starter-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-github-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-github-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-github-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-github-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slack-samples","download_url":"https://codeload.github.com/slack-samples/deno-github-functions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252967974,"owners_count":21833245,"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","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":["next-gen"],"created_at":"2025-03-14T23:17:33.211Z","updated_at":"2025-05-07T22:43:54.927Z","avatar_url":"https://github.com/slack-samples.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workflows for GitHub Sample App\n\nThis app brings oft-used GitHub functionality - such as creating new issues - to\nSlack using functions and workflows.\n\n**Guide Outline**:\n\n- [Supported Workflows](#supported-workflows)\n- [Setup](#setup)\n  - [Install the Slack CLI](#install-the-slack-cli)\n  - [Clone the Sample App](#clone-the-sample-app)\n  - [Register an OAuth App on GitHub](#register-an-oauth-app-on-github)\n  - [Configure Outgoing Domains](#configure-outgoing-domains)\n- [Create a Link Trigger](#create-a-link-trigger)\n- [Running Your Project Locally](#running-your-project-locally)\n- [Deploying Your App](#deploying-your-app)\n  - [Viewing Activity Logs](#viewing-activity-logs)\n- [Project Structure](#project-structure)\n- [Resources](#resources)\n\n---\n\n## Supported Workflows\n\n- **Create new issue**: Create and assign new issues in repositories.\n\n## Setup\n\nBefore getting started, make sure you have a development workspace where you\nhave permissions to install apps. If you don’t have one set up, go ahead and\n[create one](https://slack.com/create). Also, please note that the workspace\nrequires any of [the Slack paid plans](https://slack.com/pricing).\n\n### Install the Slack CLI\n\nTo use this sample, you first need to install and configure the Slack CLI.\nStep-by-step instructions can be found in our\n[Quickstart Guide](https://api.slack.com/automation/quickstart).\n\n### Clone the Sample App\n\nStart by cloning this repository:\n\n```zsh\n# Clone this project onto your machine\n$ slack create my-github-app -t slack-samples/deno-github-functions\n\n# Change into this project directory\n$ cd my-github-app\n```\n\n### Register a GitHub App\n\nWith [external authentication](https://api.slack.com/automation/external-auth)\nyou can connect your GitHub account to your Slack app to easily access the\nGitHub API from a custom function, creating a base for programmatic\npersonalizations!\n\n\u003e Connecting your GitHub account with external auth allows your application to\n\u003e perform the API calls used by functions as though it was _from this GitHub\n\u003e account_. This means all issues created from the **Create GitHub issue**\n\u003e workflow will appear to have been created by the account used when\n\u003e authenticating.\n\n#### Create an OAuth App on GitHub\n\nBegin by creating a new OAuth App from your\n[developer settings on GitHub](https://github.com/settings/developers) using any\n**Application name** and **Homepage URL** you'd like, but leaving **Enable\nDevice Flow** unchecked.\n\nThe **Authorization callback URL** must be set to\n`https://oauth2.slack.com/external/auth/callback` to later exchange tokens and\ncomplete the OAuth2 handshake.\n\nOnce you're satisfied with these configurations, go ahead and click **Register\napplication**!\n\n#### Add your GitHub Client ID\n\nStart by renaming the `.env.example` file at the top level of your project to\n`.env`, being sure not to commit this file to version control. This file will\nstore sensitive, app-specific variables that are determined by the environment\nbeing used.\n\nFrom your new GitHub app's dashboard, copy the **Client ID** and paste it as the\nvalue for `GITHUB_CLIENT_ID` in the `.env` file. This value will be used in\n`external_auth/github_provider.ts` – the custom OAuth2 provider definition for\nthis GitHub app.\n\nOnce complete, use `slack run` or `slack deploy` to update your local or hosted\napp!\n\n\u003e Note: Unlike environment variables used at runtime, this variable is only used\n\u003e when generating your app manifest. Therefore, you do **not** need to use the\n\u003e `slack env add` command to set this value for\n\u003e [deployed apps](#deploying-your-app).\n\n#### Generate a Client Secret\n\nReturning to your GitHub app's dashboard, press **Generate a new client secret**\nthen run the following command, replacing `GITHUB_CLIENT_SECRET` with your own\nsecret:\n\n```zsh\n$ slack external-auth add-secret --provider github --secret GITHUB_CLIENT_SECRET\n```\n\nWhen prompted to select an app, choose the `(local)` app only if you're running\nthe app locally.\n\n#### Initiate the OAuth2 Flow\n\nWith your GitHub OAuth application created and the Client ID and secret set,\nyou're ready to initate the OAuth flow!\n\nIf all the right values are in place, then the following command will prompt you\nto choose an app, select a provider (hint: choose the `github` one), then pick\nthe GitHub account you want to authenticate with:\n\n```zsh\n$ slack external-auth add\n```\n\n**Note: when working with repositories that are part of an organization, be sure\nto grant access to that organization when authorizing your OAuth app.**\n\nAfter you've added your authentication, you'll need to assign it to the\n`#/workflows/create_new_issue_workflow` workflow using the following command:\n\n```zsh\n$ slack external-auth select-auth\n```\n\nOnce you've successfully connected your account, you're almost ready to create a\nlink into your workflow!\n\n#### Collaborating with External Authentication\n\nWhen developing collaboratively on a deployed app, the external authentication\ntokens used for your app will be shared by all collaborators. For this reason,\nwe recommend creating your GitHub OAuth App using an organization account so all\ncollaborators can access the same account.\n\nLocal development does not require a shared account, as each developer will have\ntheir own local app and can individually add their own external authentication\ntokens.\n\n### Configure Outgoing Domains\n\nHosted custom functions must declare which\n[outgoing domains](https://api.slack.com/automation/manifest) are used when\nmaking network requests, including Github API calls. `api.github.com` is already\nconfigured as an outgoing domain in this sample's manifest. If your organization\nuses a separate Github Enterprise to make API calls to, add that domain to the\n`outgoingDomains` array in `manifest.ts`.\n\n## Create a Link Trigger\n\n[Triggers](https://api.slack.com/automation/triggers) are what cause workflows\nto run. These triggers can be invoked by a user, or automatically as a response\nto an event within Slack.\n\nA [link trigger](https://api.slack.com/automation/triggers/link) is a type of\nTrigger that generates a **Shortcut URL** which, when posted in a channel or\nadded as a bookmark, becomes a link. When clicked, the link trigger will run the\nassociated workflow.\n\nLink triggers are _unique to each installed version of your app_. This means\nthat Shortcut URLs will be different across each workspace, as well as between\n[locally run](#running-your-project-locally) and\n[deployed apps](#deploying-your-app). When creating a trigger, you must select\nthe Workspace that you'd like to create the trigger in. Each Workspace has a\ndevelopment version (denoted by `(local)`), as well as a deployed version.\n\nTo create a link trigger for the \"Create New Issue\" workflow, run the following\ncommand:\n\n```zsh\n$ slack trigger create --trigger-def triggers/create_new_issue_shortcut.ts\n```\n\nAfter selecting a Workspace, the output provided will include the link trigger\nShortcut URL. Copy and paste this URL into a channel as a message, or add it as\na bookmark in a channel of the workspace you selected.\n\n**Note: this link won't run the workflow until the app is either running locally\nor deployed!** Read on to learn how to run your app locally and eventually\ndeploy it to Slack hosting.\n\n## Running Your Project Locally\n\nWhile building your app, you can see your changes propagated to your workspace\nin real-time with `slack run`. In both the CLI and in Slack, you'll know an app\nis the development version if the name has the string `(local)` appended.\n\n```zsh\n# Run app locally\n$ slack run\n\nConnected, awaiting events\n```\n\nOnce running, click the\n[previously created Shortcut URL](#create-a-link-trigger) associated with the\n`(local)` version of your app. This should start a workflow that opens a form\nused to create a new GitHub issue!\n\nTo stop running locally, press `\u003cCTRL\u003e + C` to end the process.\n\n## Deploying Your App\n\nOnce you're done with development, you can deploy the production version of your\napp to Slack hosting using `slack deploy`:\n\n```zsh\n$ slack deploy\n```\n\nAfter deploying, [create a new link trigger](#create-a-link-trigger) for the\nproduction version of your app (not appended with `(local)`). Once the trigger\nis invoked, the workflow should run just as it did in when developing locally.\n\n### Viewing Activity Logs\n\nActivity logs for the production instance of your application can be viewed with\nthe `slack activity` command:\n\n```zsh\n$ slack activity\n```\n\n## Project Structure\n\n### `manifest.ts`\n\nThe [app manifest](https://api.slack.com/automation/manifest) contains the app's\nconfiguration. This file defines attributes like app name and description.\n\n### `slack.json`\n\nUsed by the CLI to interact with the project's SDK dependencies. It contains\nscript hooks that are executed by the CLI and implemented by the SDK.\n\n### `/functions`\n\n[Functions](https://api.slack.com/automation/functions) are reusable building\nblocks of automation that accept inputs, perform calculations, and provide\noutputs. Functions can be used independently or as steps in workflows.\n\n### `/workflows`\n\nA [workflow](https://api.slack.com/automation/workflows) is a set of steps that\nare executed in order. Each step in a Workflow is a function.\n\nWorkflows can be configured to run without user input or they can collect input\nby beginning with a [form](https://api.slack.com/automation/forms) before\ncontinuing to the next step.\n\n### `/triggers`\n\n[Triggers](https://api.slack.com/automation/triggers) determine when workflows\nare executed. A trigger file describes a scenario in which a workflow should be\nrun, such as a user pressing a button or when a specific event occurs.\n\n## Resources\n\nTo learn more about developing with the CLI, you can visit the following guides:\n\n- [Creating a new app with the CLI](https://api.slack.com/automation/create)\n- [Configuring your app](https://api.slack.com/automation/manifest)\n- [Developing locally](https://api.slack.com/automation/run)\n\nTo view all documentation and guides available, visit the\n[Overview page](https://api.slack.com/automation/overview).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-samples%2Fdeno-github-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslack-samples%2Fdeno-github-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-samples%2Fdeno-github-functions/lists"}