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 2866f4b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion build/command/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified bun.lockb
Binary file not shown.
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 2866f4b

Please sign in to comment.