From 04f5c77e51982fc41853d051cfa9cfc2007a2e1d Mon Sep 17 00:00:00 2001 From: Sergio Alexander Florez Galeano Date: Fri, 9 Jun 2023 17:59:44 -0500 Subject: [PATCH] Updating github actions to check packages versions --- .DS_Store | Bin 6148 -> 0 bytes .../scripts/get_github_release_log.sh | 0 .github/scripts/get_packages_upgrades.sh | 24 ++++++++++++++ .github/workflows/check_packages_versions.yml | 31 +++++++++--------- .github/workflows/release_and_publish.yml | 2 +- .gitignore | 3 ++ 6 files changed, 44 insertions(+), 16 deletions(-) delete mode 100644 .DS_Store rename get_github_release_log.sh => .github/scripts/get_github_release_log.sh (100%) create mode 100644 .github/scripts/get_packages_upgrades.sh diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 92bc65bdf54ca00ae70180b12fc64befd068ee78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ8Hu~5S@ut2-2u@xhDwt28$yXu6=>v1cE`}Ch1k>7(R<{mc0285Q`f_n(zi@ z-tO!?3B5wIBOu>LWSkqS@&D)6g-{T~Y4uqMud{_8;S z5dhdB?S{2q{ei_2z?wJ*A_LQ)0)whKVrWhd8g!i3te*peF6wW_bMnoa6N={Gp~cHZ zYak;PpaM$;R8=Km#$J1Rg0{*?mSjfZiIPs-lfe4O>#0)K&9%@uBjwNnth l9Rs}`V`J@j?L|>nY>o4pI0rf%d8Y$;88BUFRN$`__yL}f8cqNJ diff --git a/get_github_release_log.sh b/.github/scripts/get_github_release_log.sh similarity index 100% rename from get_github_release_log.sh rename to .github/scripts/get_github_release_log.sh diff --git a/.github/scripts/get_packages_upgrades.sh b/.github/scripts/get_packages_upgrades.sh new file mode 100644 index 00000000..c96e2c14 --- /dev/null +++ b/.github/scripts/get_packages_upgrades.sh @@ -0,0 +1,24 @@ +if [[ -f "packages_upgrades.txt" ]]; then + rm packages_upgrades.txt +fi + +if [[ -f "packages_upgrades_output.txt" ]]; then + rm packages_upgrades_output.txt +fi + +npm run ncu:upgrade > packages_upgrades.txt + +NO_UPGRADES_AVAILABLE_MESSAGE="All dependencies match the latest package versions :)" +if grep -q "$NO_UPGRADES_AVAILABLE_MESSAGE" packages_upgrades.txt; then + echo $NO_UPGRADES_AVAILABLE_MESSAGE +else + echo "Npm packages upgrades available:" >> packages_upgrades_output.txt + echo "" >> packages_upgrades_output.txt + while read text_line; do + if [[ "$text_line" =~ "→" ]]; then + echo "⬆️ $text_line" >> packages_upgrades_output.txt + fi + done < packages_upgrades.txt +fi + + diff --git a/.github/workflows/check_packages_versions.yml b/.github/workflows/check_packages_versions.yml index dc9aa654..7615a4a6 100644 --- a/.github/workflows/check_packages_versions.yml +++ b/.github/workflows/check_packages_versions.yml @@ -44,32 +44,33 @@ jobs: npm install - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' }} name: Step 4 - Check Packages Versions - run: npm run ncu:upgrade - - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' }} - name: Step 4 - ⚙️ Re-install dependencies with upgrades - run: npm install + run: | + bash .github/scripts/get_packages_upgrades.sh - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' }} name: Step 5 - Check Git Status - id: check_git_status_step + id: check_upgrades_available_step run: | - CHANGES_APPLIED=$(git status --porcelain | tr '\n' ' ' | tr -d '\r') - if [ "$CHANGES_APPLIED" != 'false' ]; then - CHANGES_APPLIED='true' + UPGRADES_AVAILABLE='false' + if [[ -f "packages_upgrades_output.txt" ]]; then + UPGRADES_AVAILABLE='true' fi - echo "changes_applied=$CHANGES_APPLIED" >> $GITHUB_OUTPUT - - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' && steps.check_git_status_step.outputs.changes_applied == 'true' }} + echo "upgrades_available=$UPGRADES_AVAILABLE" >> $GITHUB_OUTPUT + - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' && steps.check_upgrades_available_step.outputs.upgrades_available == 'true' }} + name: Step 6 - ⚙️ Re-install dependencies with upgrades + run: npm install + - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' && steps.check_upgrades_available_step.outputs.upgrades_available == 'true' }} id: git_commit_and_push_changes_step - name: Step 6 - Commit and push changes to repository branch + name: Step 7 - Commit and push changes to repository branch run: | git commit -am "Upgrading packages versions" git push origin $GIT_BRANCH_FOR_PACKAGES_UPGRADES - - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' && steps.check_git_status_step.outputs.changes_applied == 'true' }} - name: Step 7 - Creating pull request + - if: ${{ steps.creating_pr_step.outputs.branch_created == 'true' && steps.check_upgrades_available_step.outputs.upgrades_available == 'true' }} + name: Step 8 - Creating pull request id: creating_pull_request_step run: | gh auth login --with-token <<< "${{ secrets.AUTOMATION_GITHUB_TOKEN }}" - gh pr create --title "Upgrading packages versions" --body "Upgrading packages versions body" --base main --head $GIT_BRANCH_FOR_PACKAGES_UPGRADES + gh pr create --title "Upgrading packages versions" --body "$(cat packages_upgrades_output.txt)" --base main --head $GIT_BRANCH_FOR_PACKAGES_UPGRADES outputs: branch_created: ${{ steps.creating_pr_step.outputs.branch_created }} - changes_applied: ${{ steps.check_git_status_step.outputs.changes_applied }} + upgrades_available: ${{ steps.check_upgrades_available_step.outputs.upgrades_available }} diff --git a/.github/workflows/release_and_publish.yml b/.github/workflows/release_and_publish.yml index 943185dc..a7ca8c16 100644 --- a/.github/workflows/release_and_publish.yml +++ b/.github/workflows/release_and_publish.yml @@ -181,7 +181,7 @@ jobs: git config user.email "ops@dailybot.com" - name: Step 3 - 📄 Set GitHub release content "BODY" env var run: | - bash get_github_release_log.sh + bash .github/scripts/get_github_release_log.sh if [[ ! -f git_logs_output.txt ]]; then echo "⚠️ No description found for release body content." exit 1 diff --git a/.gitignore b/.gitignore index 96ee212d..6a86819e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ pids *.pid *.seed *.pid.lock +*.DS_Store # Directory for instrumented libs generated by jscoverage/JSCover lib-cov @@ -65,4 +66,6 @@ dist .devcontainer git_logs.txt git_logs_output.txt +packages_upgrades.txt +packages_upgrades_output.txt emoji-lib-output.json