Skip to content

Commit

Permalink
Allow overriding the command passed to Expo
Browse files Browse the repository at this point in the history
You may want to call into the command action using a provided command
string rather than what comes from the GitHub Action.

This is useful if you want to write an action that listens for a
specific shortcut (e.g. `#release production`) which then calls the
expo/eas command supported by the official action. Then you benefit from
the nice shortcut, remove the possibility of misconfiguration, while
keeping the official GHA's behaviour like posting builds back to the PR
or responding to the original comment.
  • Loading branch information
lawrencejones committed Jun 4, 2024
1 parent 89b4994 commit 0aea399
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions command/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ inputs:
description: GitHub access token to comment on PRs
required: false
default: ${{ github.token }}
command-override:
description: Command to run (if not provided, taken from comment)
required: false
9 changes: 8 additions & 1 deletion src/actions/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function commandInput() {
return {
reaction: '+1' as Reaction['content'],
githubToken: getInput('github-token'),
commandOverride: getInput('command-override'),
};
}

Expand All @@ -31,7 +32,13 @@ export async function commandAction(input = commandInput()) {
return;
}

const command = parseCommand(comment);
let commandSource = comment;
if (input.commandOverride) {
info(`Overriding command with: ${input.commandOverride}`);
commandSource = input.commandOverride;
}

const command = parseCommand(commandSource);
if (!command) {
info("Comment didn't contain a valid expo/eas command");
return;
Expand Down

0 comments on commit 0aea399

Please sign in to comment.