|
1 | | -# GitHub Repos workflow for Alfred |
| 1 | +# GitHub Repos Alfred Workflow |
2 | 2 |
|
3 | | -This is a custom workflow for the [Alfred app][alfred-app] that lets you search and open a GitHub repository via the GitHub Search API. |
| 3 | +This [Alfred](https://www.alfredapp.com/) workflow lets you search for GitHub |
| 4 | +repositories right from the Alfred bar. |
| 5 | + |
| 6 | +It uses the [GitHub CLI](https://github.com/cli/cli) under the hood. |
| 7 | + |
| 8 | +## Requirements |
| 9 | + |
| 10 | +Install the GitHub CLI: |
| 11 | + |
| 12 | +```bash |
| 13 | +# Run this in the terminal: |
| 14 | +brew install gh |
| 15 | +``` |
| 16 | + |
| 17 | +> 💡 **Note**: |
| 18 | +> The command above assume you use [Homebrew](https://brew.sh) as your package manager. |
4 | 19 |
|
5 | 20 | ## Authentication |
6 | 21 |
|
7 | | -You'll need to authenticate with a personal access token that you can generate in the [GitHub developer settings page][personal-access-token] or by running the `gh-token` command in Alfred. |
| 22 | +Authentication is handled by the GitHub CLI, so just follow the instructions when running: |
8 | 23 |
|
9 | | -After you have copied your personal access token, run `gh-login <your-token>` to set your personal access token. |
| 24 | +```bash |
| 25 | +# Run this in the terminal: |
| 26 | +gh auth login |
| 27 | +``` |
10 | 28 |
|
11 | | -## Usage |
| 29 | +## Installation |
12 | 30 |
|
13 | | -Here's the list of available commands. |
| 31 | +You can download the workflow from the [releases page](https://github.com/edgarjs/github-repos-alfred-workflow/releases) |
| 32 | +or from [Packal](https://www.packal.org/workflow/github-repos). |
14 | 33 |
|
15 | | -### Global Search: `gh <query>` |
| 34 | +Double click on the `.alfredworkflow` file and follow the instructions. |
16 | 35 |
|
17 | | - |
| 36 | +## Usage |
18 | 37 |
|
19 | | -The example above will search for repositories with the string "hello-world" in their name. Internally this uses the [GitHub Search syntax][github-search], so you can use modifiers like: |
| 38 | +There's a single keyword that triggers the workflow: `gh` |
20 | 39 |
|
21 | | - |
| 40 | +Then you can start typing the name of the repository you're looking for. |
| 41 | +It will first try to search within your user's repositories. And if no result |
| 42 | +is found, then it'll search in all public repositories. |
22 | 43 |
|
23 | | -This will search only in repositories that have more than 1000 stars. |
| 44 | +``` |
| 45 | +gh octocat/hello-world |
| 46 | +``` |
24 | 47 |
|
25 | | -> Please note that this command only searches in the repository name. This means that your query will be appended with the `in:name` modifier. So when you type in `hello-world`, the final search query sent will be: "hello-world in:name". |
| 48 | + |
26 | 49 |
|
27 | | -### Search your repositories: `repo [query]` |
| 50 | +When an item is highlighted, you can press Enter to open the repository's page, |
| 51 | +or press any of the following modifiers keys for other options: |
28 | 52 |
|
29 | | -This command works the same as the previous one (`gh <query>`) but it limits the search to your own repositories. |
| 53 | +### Hold `Ctrl ⌃` for repository actions page |
30 | 54 |
|
31 | | -> This includes repositories from your organizations as well. |
| 55 | +Press Enter while holding down the `Ctrl` key to open the repository's actions page. |
32 | 56 |
|
33 | | -### Search Pull Requests: `pr [query]` |
| 57 | +### Hold `Cmd ⌘` to see Pull Requests |
34 | 58 |
|
35 | | -This command searches within the Pull Requests that you're involved in. |
| 59 | +Press Enter while holding down the `Cmd` key to list the repository's open PR's. |
36 | 60 |
|
37 | | -If you want to limit the search to be under your organisations, please remove `PR_ALL_INVOLVE_ME` environment variable |
| 61 | +### `Option ⌥` modifier |
38 | 62 |
|
39 | | -### Open notifications: `gh-notifications` |
| 63 | +Press Enter while holding down the `Option` key to copy the clone command with the repository's SSH URL. |
40 | 64 |
|
41 | | -This command just opens your [GitHub notification][notifications-page] page. |
| 65 | +### `Shift+Option ⇧+⌥` modifier |
42 | 66 |
|
43 | | -## Config Cache TTL |
| 67 | +Press Enter while holding down the `Shift+Option` keys to copy the clone command with the repository's clone URL. |
44 | 68 |
|
45 | | -You can customise the TTL for the internal caches of Repos/Organisations/PullRequests by seting the following |
46 | | -environment variables. (all in seconds) |
| 69 | +## Configuration |
47 | 70 |
|
48 | | -``` |
49 | | -> CACHE_TTL_SEC_ORG default: 86400 |
50 | | -> CACHE_TTL_SEC_PR default: 300 |
51 | | -> CACHE_TTL_SEC_REPO default: 86400 |
52 | | -``` |
| 71 | +### API Response Caching |
53 | 72 |
|
| 73 | +You can configure the cache duration passed to the GitHub CLI, by setting the following environment variables. |
54 | 74 |
|
55 | | -## Configuring host for Enterprise |
| 75 | +| Environment Variable | Description | Default | |
| 76 | +| -------------------- | ---------------------------------------- | ----------------- | |
| 77 | +| `CACHE_PULLS` | Cache duration for PR's API call | `10m` | |
| 78 | +| `CACHE_SEARCH_REPOS` | Cache duration for repos search API call | `24h` | |
| 79 | +| `CACHE_USER_REPOS` | Cache duration for user repos API call | `72h` | |
| 80 | +| `CACHE_DIR` | Cache directory for the the `gh` CLI | `$HOME/.cache/gh` | |
56 | 81 |
|
57 | | -If you're using an Enterprise account, you can call the `gh-host <host>` command. |
| 82 | +> ⚠️ **Caution** ⚠️ |
| 83 | +> |
| 84 | +> If you don't see your recently created repository in the results, it may be the cache duration mentioned above. |
| 85 | +> |
| 86 | +> Also make sure to use absolute paths if you need to customize the default. |
| 87 | +> Like `/Users/juan/cache` instead `$HOME/cache` |
58 | 88 |
|
59 | | ---- |
| 89 | +To clear the cache and force a new request to the GitHub API, type this in Alfred: |
60 | 90 |
|
61 | | -## Contributing |
| 91 | +``` |
| 92 | +ghclear |
| 93 | +``` |
62 | 94 |
|
63 | | -You can submit your bug reports or feature requests at: |
64 | | -https://github.com/edgarjs/alfred-github-repos/issues |
| 95 | +### Enterprise Host |
65 | 96 |
|
66 | | -If you want to submit a Pull Request, please follow these simple guides: |
| 97 | +If you're using an Enterprise account, you can set the following environment variable to your needs: |
67 | 98 |
|
68 | | -1. Add a detailed description of what you're changing and why. |
69 | | -2. Add necessary unit tests that cover your changes. |
70 | | -3. Don't increase the version of the workflow in your changes. |
| 99 | +| Environment Variable | Description | Default | |
| 100 | +| -------------------- | --------------------------------- | ------------ | |
| 101 | +| `API_HOST` | Hostname to use for the API calls | `github.com` | |
71 | 102 |
|
72 | | -Here are some ideas for Pull Requests: |
| 103 | +## Contributing |
73 | 104 |
|
74 | | -- [ ] Make search faster |
75 | | -- [ ] Search commits in a repository |
76 | | -- [ ] Search projects in an organization |
77 | | -- [ ] Improve icon graphics |
| 105 | +You can submit your bug reports or feature requests at: |
| 106 | +https://github.com/edgarjs/github-repos-alfred-workflow/issues |
78 | 107 |
|
79 | 108 | ## License |
80 | 109 |
|
81 | 110 | This project is published under the [MIT License](LICENSE.md). |
82 | | - |
83 | | -[alfred-app]: https://www.alfredapp.com/ |
84 | | -[github-search]: https://docs.github.com/en/free-pro-team@latest/github/searching-for-information-on-github/searching-on-github |
85 | | -[download-packal]: https://www.packal.org/workflow/github-repos |
86 | | -[download-releases]: https://github.com/edgarjs/alfred-github-repos/releases |
87 | | -[personal-access-token]: https://github.com/settings/tokens/new?description=GitHub%20Repos%20Alfred%20workflow&scopes=repo |
88 | | -[pulls-page]: https://github.com/pulls |
89 | | -[notifications-page]: https://github.com/notifications |
90 | | -[alfred-env-vars]: https://www.alfredapp.com/help/workflows/script-environment-variables/ |
|
0 commit comments