Jump to content

Recommended Posts

Github workflow for Alfred v2

A configurable workflow for Alfred v2.

screenshot-repo-list.png

Installation

You can install this workflow by dowloading the Github.alfredworkflow file and either double-clicking it, or dragging it onto the Alfred Workflow screen.

After adding it to your workflow collection, when you run the gh command in Alfred you will be presented with only two options; auth and token.

screenshot-no-auth.png

First, you'll need to choose for the auth option, this will generate an OAuth token for you which will be used by all subsequent calls to the Github API.

Once you get the OAuth token, copy it from the website, run gh token and paste the OAuth token in the Alfred window.

gh token thisisthetokenwhichcamefromthewebsite

 

Now you're all set to start using this workflow!

 

Usage

The initial command for starting this workflow is gh.

The commands currently supported by this workflow are:

  • repo
    This returns a list of options for listing your repositories screenshot-repo.png

You can filter the results show by typing (part of) the repositoryname after the workflow command, f.e.: screenshot-repo-list-filtered.png

 

If there's anything you run into which isn't working as you expect, or not working at all for some reason. Please, do let me know!

 

Also, be sure to check out the repository and maybe make some additions yourself!

Edited by RevellNL

Share this post


Link to post

(…) be sure to enter your own username and password in the script filter within the workflow. (These aren't stored anywhere outside of the script filter (…)

 

It can still be seen as a security risk (albeit only in very specific cases). Since it’s saved in plaintext, someone can still snoop around (not to mention it’ll probably be uploaded do Dropbox).

Maybe there’s an easy way to do it via OAuth.

Edited by Vítor

Share this post


Link to post

OAuth is definitely the way to go and I'll certainly be looking into it!

 

For now I'm just going to be trying to make this works and have some nice functionality before I fix that though.

Share this post


Link to post

Had a quick look at integrating OAuth into the worklflow and it seems to be pretty simple, only thing is that you'll need to perform some manual steps in order to get the workflow to properly communicate with Github.
 
You'd have to authenticate via a github webpage after which you'll get redirected to a page under my control where a OAuth consumer key will be shown, this key would then have to be pasted into the Alfred workflow after which everything should work.
 
I don't really see this as a huge step, but I'm wondering what you guys think about this. Would you prefer to see the authentication go through OAuth (and perform the above steps once?), or would you prefer to just enter your credentials as it is now, in plain-text?

Share this post


Link to post

Maybe you could write a quick config AppleScript type thing that would create dialog boxes to enter in the credentials (then put in an action launched by something like "github configure"), and then you could encrypt the user and password from there.

Edited by Shawn Rice

Share this post


Link to post

I'm working on the OAuth integration now, I have the flow laid out, now I just need to implement it. Should be fairly simple to do and with little to no effort needed from the user.

Share this post


Link to post

When you have two commands (“gh” and “gh_auth”) people will constantly see the auth command when wanting to do the other, which in my view adds some unnecessary visual clutter (seeing as it’s a command that’ll only be run once).

I’d make a suggestion, which is similar to what I’ve implemented on PinAdd — make it an action modifier

AUntLTv.png

Share this post


Link to post

This crossed my mind as well. Another way I thought of this is to store the OAuth token in a separate file so it will be remembered after an update as well (currently it isn't), this way I can also check if that file is present, with content, and if so, I wont show the 'auth' command.

Share this post


Link to post

This crossed my mind as well. Another way I thought of this is to store the OAuth token in a separate file so it will be remembered after an update as well (currently it isn't), this way I can also check if that file is present, with content, and if so, I wont show the 'auth' command.

 

That’s also how I’ve set it up to work in PinAdd. Another advantage of it is that it’s also easier to update, since every time you want to push a new version you simply remove that file from the directory, instead of having to manually remove the key from the script.

Edited by Vítor

Share this post


Link to post

 

That’s also how I’ve set it up to work in PinAdd. Another advantage of it is that it’s also easier to update, since every time you want to push a new version you simply remove that file from the directory, instead of having to manually remove the key from the script.

You don't have to remove the key at all if you want to push a new version. I'm storing it in the non-volatile workflow directory (~/Library/Application Support/Alfred 2/Workflow Data/nl.jeroenseegers.Alfred.Github) so it will remain after updates as well and it won't get pushed with a new version!

Share this post


Link to post

Just pushed a minor update, ability to list watched repositories is now added.

 

Depending on the amount of repositories you own and have starred/watched the initial listing might take a while since the Github API doesn't respond that fast. After the initial call the repolists will be cached for 5 minutes by default.

Edited by RevellNL

Share this post


Link to post

You don't have to remove the key at all if you want to push a new version. I'm storing it in the non-volatile workflow directory (~/Library/Application Support/Alfred 2/Workflow Data/nl.jeroenseegers.Alfred.Github) so it will remain after updates as well and it won't get pushed with a new version!

 

You’re right. I prefer to store it in the workflow’s directory so it syncs, but I can certainly understand the decision to keep it there.

Share this post


Link to post

I've just updated the workflow with support for the Alleyoop updating mechanism, this will make updating the workflow in the future less cumbersome!

 

Download the workflow update here (possibly the last time you'll have to download manually, yay!)

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...