From a52e3f39ddf92f9d36bfe2f36e89873a1e127614 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 8 Oct 2022 11:08:08 +0530 Subject: Only run the dependencies update if there are any changes to be deployed --- .github/workflows/builds.yml | 57 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to '.github/workflows/builds.yml') diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 6721996d6..6c9df8950 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -26,7 +26,7 @@ on: description: "Message for build" required: true schedule: - - cron: "15 0 * * *" # every night at 12:15 am (to allow for dependency builds to complete) + - cron: '0 0 * * *' # every night at 12 am env: USE_HARD_LINKS: false @@ -95,6 +95,61 @@ jobs: git push origin $(git rev-parse --abbrev-ref HEAD) --no-verify fi + dependency_updates: + name: "Update dependencies" + runs-on: ubuntu-20.04 + needs: check_updates + if: ${{ needs.check_updates.outputs.should_run != 'false' }} + steps: + - name: Set env vars + run: | + echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV + echo "PNPM_CACHE=$HOME/.pnpm-store" >> $GITHUB_ENV + - name: Checkout code along with submodules + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # Note: Needed to be able to pull the 'develop' branch as well for merging + - name: Extract Git branch name and commit from the currently checked out branch (not from the branch where this run was kicked off) + run: | + echo "GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV + shell: bash + - name: Use Node.js specified in the '.nvmrc' file + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + - name: Install npm + run: npm i -gf "npm@$(node -p 'require("./package.json").engines.npm')" && npm -v + - name: Install pnpm + run: npm i -gf "pnpm@$(node -p 'require("./recipes/package.json").engines.pnpm')" && pnpm -v + - name: Install node dependencies + run: npm i + - name: Update submodules + run: | + rm -rf ./recipes + npm run update-submodules + git add . + echo "GIT_DIRTY=$(git status -s | wc -l)" >> $GITHUB_ENV + - name: Update browserslist db + run: | + npx browserslist@latest --update-db + git add . + echo "GIT_DIRTY=$(git status -s | wc -l)" >> $GITHUB_ENV + - name: Run linter, reformatter, rebrander and tests + if: ${{ env.GIT_DIRTY != '0' }} + run: | + npm run prepare-code + npm run test + - name: Commit submodules, dependency-updates and linter changes + if: ${{ env.GIT_DIRTY != '0' }} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git commit -am "Update submodules, browserslist data updates and linter fixes [skip ci]" --no-verify || true + - name: Push all changes + if: ${{ env.GIT_DIRTY != '0' }} + run: git push origin ${{ env.GIT_BRANCH_NAME }} --no-verify + build_mac: name: "macos ${{ github.event.inputs.message }}" needs: check_updates -- cgit v1.2.3-70-g09d2