aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/dependency-updates.yml
blob: 0f6befb55f9d2beadff80fc3f669e4aa24070daa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This workflow will do a clean install of ferdium dev-dependencies, update the dependencies, build the source code and run tests. It will only run on scheduled trigger.

name: 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
          echo "PNPM_CACHE=$HOME/.pnpm-store" >> $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
        shell: bash
      - name: Use Node.js specified in the '.nvmrc' file
        uses: actions/setup-node@v2
        with:
          node-version-file: '.nvmrc'
      - name: Install pnpm
        uses: pnpm/action-setup@v2.0.1
        with:
          version: 6.24.1
      - 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