From 77322dfba93d33767c1d032847af56ad4dfd5e96 Mon Sep 17 00:00:00 2001 From: Jasper Furniss Date: Wed, 4 Sep 2024 13:23:12 -0400 Subject: [PATCH] Implement Error Handling and Additions for Github Action (#3652) **What does this PR do?** A clear and concise description with your runway ticket url. **Screenshots:** Screenshots to visualize your addition/change **How to test?** Steps to confirm the desired behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See addition/change #### Checklist: - [ ] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [ ] **DEPLOY** I have added the `milano` label to show I'm ready for a review. - [ ] **TESTS** I have added test coverage to my code. --- .../github-actions-release-candidate.yml | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-release-candidate.yml b/.github/workflows/github-actions-release-candidate.yml index cdbbb09496..8ae9328e42 100644 --- a/.github/workflows/github-actions-release-candidate.yml +++ b/.github/workflows/github-actions-release-candidate.yml @@ -55,11 +55,24 @@ jobs: echo "new_ruby_version=${new_ruby_version}" >> $GITHUB_ENV - name: Check if version exists and increment if necessary run: | - while npm view playbook-ui@${{ env.new_npm_version }} version &>/dev/null; do - new_npm_version=$(yarn version --prerelease --preid rc --no-git-tag-version | grep "New version:" | awk '{print $4}') - new_npm_version=${new_npm_version#v} - echo "new_npm_version=${new_npm_version}" >> $GITHUB_ENV + max_attempts=2 + attempt=0 + while [ $attempt -lt $max_attempts ]; do + if timeout 30s npm view playbook-ui@${{ env.new_npm_version }} version &>/dev/null; then + echo "Version ${{ env.new_npm_version }} already exists. Incrementing..." + new_npm_version=$(yarn version --prerelease --preid rc --no-git-tag-version | grep "New version:" | awk '{print $4}') + new_npm_version=${new_npm_version#v} + echo "new_npm_version=${new_npm_version}" >> $GITHUB_ENV + else + echo "Version ${{ env.new_npm_version }} is available." + break + fi + attempt=$((attempt+1)) done + if [ $attempt -eq $max_attempts ]; then + echo "Error: Maximum attempts reached. Unable to find an available version." + exit 1 + fi new_ruby_version=$(echo $new_npm_version | sed 's/-rc\./.pre.rc./') echo "new_ruby_version=${new_ruby_version}" >> $GITHUB_ENV - name: Update Version.rb