# This workflow will do a clean install of ferdi dev-dependencies, update the dependencies, build the source code and run tests. It will only run on scheduled trigger. name: Ferdi Dependency updates on: # Manual trigger from the UI workflow_dispatch: inputs: message: description: 'Message for build' required: true schedule: - cron: '0 0 * * *' # every night at 12 am env: USE_HARD_LINKS: false jobs: dependency_updates: runs-on: ubuntu-latest steps: - name: Set env vars run: | echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV - name: Checkout code along with submodules uses: actions/checkout@v2 with: submodules: recursive - 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 echo "GIT_COMMIT=$(git log -1 --format='%H')" >> $GITHUB_ENV shell: bash - name: Cache node modules uses: actions/cache@v2 env: cache-name: cache-node-modules with: path: ${{ env.NPM_CACHE }} key: ${{ runner.os }}-14.17-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-14.17-build-${{ env.cache-name }}- ${{ runner.os }}-14.17-build- - name: Use Node.js 14.17.3 uses: actions/setup-node@v2 with: node-version: 14.17.3 - name: Uninstall locally and reinstall node-gyp globally run: | npm uninstall node-gyp npm i -g node-gyp@8.0.0 && npm config set node_gyp "$(which node-gyp)" - name: Install node dependencies recursively run: npx lerna bootstrap - name: Update submodules run: npm run update-submodules - name: Update browserslist db run: npx browserslist@latest --update-db - name: Run linter, reformatter, rebrander and tests run: | npm run prepare-code npm run test - name: Commit submodules, dependency-updates and linter changes 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 echo "CHANGES_COUNT=$(git diff ${{ env.GIT_COMMIT }} | wc -l)" >> $GITHUB_ENV - name: Bump version number if this is a scheduled build with changes or has been manually triggered with 'version bump' in the text, then bump the version number if: ${{ (github.event_name == 'schedule' && env.CHANGES_COUNT != '0') || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, 'version bump')) }} run: npm version prerelease --preid=nightly - name: Push all changes run: git push origin ${{ env.GIT_BRANCH_NAME }} --no-verify