Skip to content

Commit 20e85a2

Browse files
committed
Rewrite to use the GitHub CLI instead of custom implementation
1 parent 2c60c91 commit 20e85a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+799
-2950
lines changed

.circleci/config.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.editorconfig

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build and release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
release:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Build workflow artifact
22+
run: bash build.sh
23+
24+
- name: Generate Changelog
25+
run: git log $(git tag --sort=-creatordate | awk 'NR==2')..HEAD^1 --oneline --no-merges --no-decorate > CHANGELOG
26+
27+
- name: Create GitHub Release
28+
uses: softprops/action-gh-release@v2
29+
with:
30+
files: build/github-repos.alfredworkflow
31+
body_path: CHANGELOG
32+
make_latest: true
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
*.alfredworkflow
22
build/
3-
coverage/
4-
out/
5-
tmp/

Gemfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 57 deletions
This file was deleted.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Edgar Suarez
3+
Copyright (c) Edgar Suarez (edgarjs)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 72 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,110 @@
1-
# GitHub Repos workflow for Alfred
1+
# GitHub Repos Alfred Workflow
22

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.
419
520
## Authentication
621

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:
823

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+
```
1028

11-
## Usage
29+
## Installation
1230

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).
1433

15-
### Global Search: `gh <query>`
34+
Double click on the `.alfredworkflow` file and follow the instructions.
1635

17-
![gh hello-world](docs/gh-hello-world.png)
36+
## Usage
1837

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`
2039

21-
![gh hello-world stars:>1000](docs/gh-hello-world-stars-1000.png)
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.
2243

23-
This will search only in repositories that have more than 1000 stars.
44+
```
45+
gh octocat/hello-world
46+
```
2447

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+
![Example of gh command](gh.png)
2649

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:
2852

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
3054

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.
3256

33-
### Search Pull Requests: `pr [query]`
57+
### Hold `Cmd ⌘` to see Pull Requests
3458

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.
3660

37-
If you want to limit the search to be under your organisations, please remove `PR_ALL_INVOLVE_ME` environment variable
61+
### `Option ⌥` modifier
3862

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.
4064

41-
This command just opens your [GitHub notification][notifications-page] page.
65+
### `Shift+Option ⇧+⌥` modifier
4266

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.
4468

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
4770

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
5372

73+
You can configure the cache duration passed to the GitHub CLI, by setting the following environment variables.
5474

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` |
5681

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`
5888
59-
---
89+
To clear the cache and force a new request to the GitHub API, type this in Alfred:
6090

61-
## Contributing
91+
```
92+
ghclear
93+
```
6294

63-
You can submit your bug reports or feature requests at:
64-
https://github.com/edgarjs/alfred-github-repos/issues
95+
### Enterprise Host
6596

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:
6798

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` |
71102

72-
Here are some ideas for Pull Requests:
103+
## Contributing
73104

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
78107

79108
## License
80109

81110
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/

Rakefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)