New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve simultaneous deployments with rebase #1054
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2fd4ec1
Return early from dry run
rossjrw 195bb64
Add force parameter to action interface
rossjrw 50ec836
Implement pull+rebase procedure
rossjrw 1a57670
Declare force parameter in action
rossjrw 451d4b5
Detect both rejection syntaxes
rossjrw 81ec18c
Return both stdout and stderr from execute
rossjrw 8fc8cde
Ignore non-zero exit status on push
rossjrw bfda3cd
Remove unnecessary error catch
rossjrw 37d5e1e
Fetch and rebase in separate steps
rossjrw f1e9c66
Explicitly bind incoming branch
rossjrw 4671cb9
Implement attempt limit
rossjrw ca888b7
Update tests for execute output split
rossjrw 507eec6
Document 'force' parameter
rossjrw a0fbdd6
Create integration test for rebase procedure
rossjrw File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,58 @@ | ||
import {exec} from '@actions/exec' | ||
import buffer from 'buffer' | ||
|
||
let output = '' | ||
type ExecuteOutput = { | ||
stdout: string | ||
stderr: string | ||
} | ||
|
||
const output: ExecuteOutput = {stdout: '', stderr: ''} | ||
|
||
/** Wrapper around the GitHub toolkit exec command which returns the output. | ||
* Also allows you to easily toggle the current working directory. | ||
* | ||
* @param {string} cmd - The command to execute. | ||
* @param {string} cwd - The current working directory. | ||
* @param {boolean} silent - Determines if the in/out should be silenced or not. | ||
* @param {boolean} ignoreReturnCode - Determines whether to throw an error | ||
* on a non-zero exit status or to leave implementation up to the caller. | ||
*/ | ||
export async function execute( | ||
cmd: string, | ||
cwd: string, | ||
silent: boolean | ||
): Promise<string> { | ||
output = '' | ||
silent: boolean, | ||
ignoreReturnCode = false | ||
): Promise<ExecuteOutput> { | ||
output.stdout = '' | ||
output.stderr = '' | ||
|
||
await exec(cmd, [], { | ||
// Silences the input unless the INPUT_DEBUG flag is set. | ||
silent, | ||
cwd, | ||
listeners: { | ||
stdout | ||
} | ||
listeners: {stdout, stderr}, | ||
ignoreReturnCode | ||
}) | ||
|
||
return Promise.resolve(output) | ||
} | ||
|
||
export function stdout(data: Buffer | string): void { | ||
const dataString = data.toString().trim() | ||
if (output.length + dataString.length < buffer.constants.MAX_STRING_LENGTH) { | ||
output += dataString | ||
if ( | ||
output.stdout.length + dataString.length < | ||
buffer.constants.MAX_STRING_LENGTH | ||
) { | ||
output.stdout += dataString | ||
} | ||
} | ||
|
||
export function stderr(data: Buffer | string): void { | ||
const dataString = data.toString().trim() | ||
if ( | ||
output.stderr.length + dataString.length < | ||
buffer.constants.MAX_STRING_LENGTH | ||
) { | ||
output.stderr += dataString | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this to the README under the
Optional Choices
section?