-
Notifications
You must be signed in to change notification settings - Fork 20
Add Retry for Remote Application, Addon, and EC2 Instance Inline #9
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
Merged
+199
−46
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d5560d7
Test
harrryr d92917b
Test
harrryr 97ac117
Test
harrryr bdf1566
Merge remote-tracking branch 'origin' into retry-remote-application-a…
harrryr 9005f19
Check if remote application is deployed properly
harrryr 759c205
Add comment, increase retry count for gradlew
harrryr e7a44e0
Fix comment
harrryr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Reusable Action for executing commands and retrying them if it fails | ||
name: Command Retry Logic | ||
|
||
inputs: | ||
# (Optional) Command to run before the retry command. To be used for environment setup, etc | ||
pre-command: | ||
required: false | ||
type: string | ||
# (Optional) Number of retries to perform. Default is 2 | ||
max_retry: | ||
required: false | ||
type: number | ||
default: 2 | ||
# (Required) Command to execute with the retry mechanism | ||
command: | ||
required: true | ||
type: string | ||
# (Required) Command to clean up resources before retrying the main command | ||
cleanup: | ||
required: false | ||
type: string | ||
# (Optional) Follow-up command after the main command is finished. | ||
post-command: | ||
required: false | ||
type: string | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Run pre-command | ||
shell: bash | ||
env: | ||
PRE_COMMAND: ${{ inputs.pre-command }} | ||
run: | | ||
$PRE_COMMAND | ||
|
||
- name: Run command | ||
shell: bash | ||
env: | ||
MAX_RETRY: ${{ inputs.max_retry }} | ||
COMMAND: ${{ inputs.command }} | ||
CLEANUP: ${{ inputs.cleanup }} | ||
run: | | ||
retry_counter=0 | ||
while [ $retry_counter -lt $MAX_RETRY ]; do | ||
attempt_failed=0 | ||
eval "$COMMAND" || attempt_failed=$? | ||
|
||
if [ $attempt_failed -ne 0 ]; then | ||
eval "$CLEANUP" | ||
retry_counter=$(($retry_counter+1)) | ||
sleep 5 | ||
else | ||
break | ||
fi | ||
|
||
if [ $retry_counter -eq $max_retry ]; then | ||
echo "Max retry reached, command failed to execute properly. Exiting code" | ||
exit 1 | ||
fi | ||
done | ||
|
||
- name: Run post command | ||
shell: bash | ||
env: | ||
POST_COMMAND: ${{ inputs.post-command }} | ||
run: $POST_COMMAND |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.