Check first for existing branches before creating them#18
Check first for existing branches before creating them#18wrandall22 wants to merge 2 commits intoyinlinchen:masterfrom
Conversation
|
This needs more work still, unfortunately, |
103f05a to
97414c2
Compare
dca3e4d to
3484068
Compare
|
I believe this is working now (tested on a non-existing and existing branch). However, there is a side effect of a log in the console: |
|
Is there anything else missing we could do to merge this one? cc @yinlinchen @wrandall22 I'd be glad to help if needed, these errors for existing branches are bothering us a lot here 😅 |
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that a new Amplify branch is only created when it does not already exist, addressing issue #10. Key changes include:
- Adding a branch existence check using aws amplify get-branch.
- Conditional branch creation with appropriate echo statements.
- Maintaining debug logging for deployment feedback.
Comments suppressed due to low confidence (1)
entrypoint.sh:59
- Similarly, in the create-branch command, wrapping the variables in quotes can help ensure robust parsing of parameters.
sh -c "aws amplify create-branch --app-id=${AmplifyAppId} --branch-name=$BRANCH_NAME \
| sleep 10 | ||
| echo "deploying" | ||
|
|
||
| if [[ -z $(aws amplify get-branch --app-id=${AmplifyAppId} --branch-name=$BRANCH_NAME --region=${AWS_REGION} 2> /dev/null) ]]; then |
There was a problem hiding this comment.
To avoid potential issues with word splitting or globbing, consider quoting the variables (e.g., "${AmplifyAppId}", "$BRANCH_NAME", "${AWS_REGION}") in the shell command.
We have been using it in production for over a year with our fork. Haven't seen any issues with it that I'm aware of. We also made another change here later. |
This PR is another attempt at fixing issue #10 after the reversion in #12. I found the echo lines to be helpful, but we can delete them if desired.