I want to create an action that will run a shell command from a given directory.
Specifically I need to run this:
gh run download -n firmware -D ~/Downloads
That will download the last successful build from GitHub Actions into my Downloads folder if, and only if I'm doing this on a terminal inside my repo's folder.
So here's my question: is there a way to use the run shell command action to do this (or any other action for that matter)?
I'm sure there's a Unixy way to do it fast, but the first solution that comes to mind is this:
Shell script, save to variable: pwd
That puts the working directory in a variable. Then use a Case action, where you check if the variable includes the path to the folder of interest. If it does, then run your real shell script command.
Edit: I based the above on you wanting a macro to run when you were actively in Terminal. I may have misread the post; are you just wanting a macro you can run from anywhere that runs that command in your repo's folder?
Sounds like you want to put a command into Terminal that'll only do something when you are in a certain directory (which is much easier than only putting the command into Terminal if you are in a certain directory).
...where the shell script bit is
if [[ $(pwd) == "/Users/lucas/path/to/github project" ]]; then gh run download -n firmware -D ~/Downloads; else echo "Wrong directory";fi
Change the path to suit.
I've included the Return key in the pasted text, which will fire the command of in one go. But you could remove that and use a "Type a Keystroke: Return" action instead.
You could use an Hot Key or a Typed String trigger to run a macro containing just this action or build it in to a bigger workflow.