Skip to content

Commit

Permalink
Updating github actions to check packages versions
Browse files Browse the repository at this point in the history
  • Loading branch information
xergioalex committed Jun 9, 2023
1 parent 78d1623 commit 04f5c77
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
Binary file removed .DS_Store
Binary file not shown.
File renamed without changes.
24 changes: 24 additions & 0 deletions .github/scripts/get_packages_upgrades.sh
Original file line number Diff line number Diff line change
@@ -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


31 changes: 16 additions & 15 deletions .github/workflows/check_packages_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/release_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pids
*.pid
*.seed
*.pid.lock
*.DS_Store

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
Expand Down Expand Up @@ -65,4 +66,6 @@ dist
.devcontainer
git_logs.txt
git_logs_output.txt
packages_upgrades.txt
packages_upgrades_output.txt
emoji-lib-output.json

0 comments on commit 04f5c77

Please sign in to comment.