xref: /expo/.github/workflows/sdk.yml (revision bb8f4f99)
1name: SDK
2
3on:
4  workflow_dispatch:
5    inputs:
6      checkAll:
7        description: 'type "check-all" to force checking all packages'
8        required: false
9        default: ''
10  push:
11    branches: [master, 'sdk-*']
12    paths:
13      - .github/workflows/sdk.yml
14      - tools/**
15      - packages/**
16      - yarn.lock
17  pull_request:
18    branches: [master]
19    paths:
20      - .github/workflows/sdk.yml
21      - tools/**
22      - packages/**
23      - yarn.lock
24  schedule:
25    - cron: 0 14 * * *
26
27jobs:
28  check-packages:
29    runs-on: ubuntu-18.04
30    steps:
31      - name: �� Checkout a ref for the event
32        uses: actions/checkout@v2
33        with:
34          fetch-depth: 100
35      - name: ⬇️ Fetch commits from base branch
36        run: git fetch origin ${{ github.event.before || github.base_ref || 'master' }}:${{ github.event.before || github.base_ref || 'master' }} --depth 100
37        if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
38      - name: ♻️ Restore workspace node modules
39        uses: actions/cache@v2
40        id: node-modules-cache
41        with:
42          path: |
43            # See "workspaces" → "packages" in the root package.json for the source of truth of
44            # which node_modules are affected by the root yarn.lock
45            node_modules
46            apps/*/node_modules
47            home/node_modules
48            packages/*/node_modules
49            packages/@unimodules/*/node_modules
50            react-native-lab/react-native/node_modules
51          key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
52      - name: �� Install node modules in root dir
53        # if: steps.node-modules-cache.outputs.cache-hit != 'true'
54        run: yarn install --frozen-lockfile
55      - name: ♻️ Restore node modules in tools
56        uses: actions/cache@v2
57        with:
58          path: tools/node_modules
59          key: ${{ runner.os }}-modules-${{ hashFiles('tools/yarn.lock') }}
60      - name: �� Check packages
61        run: |
62          echo "Checking packages according to the event name: ${{ github.event_name }}"
63          if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event.inputs.checkAll }}" == "check-all" ]]; then
64            # Check all packages on scheduled events or if requested by workflow_dispatch event.
65            bin/expotools check-packages --all
66          else
67            # On push event check packages changed since previous remote head.
68            # In pull requests and workflow_dispatch events check all packages changed in the entire PR.
69            bin/expotools check-packages --since ${{ github.event.before || github.base_ref || 'master' }}
70          fi
71      - name: �� Notify on Slack
72        uses: 8398a7/action-slack@v3
73        if: failure() && (github.event.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/heads/sdk-'))
74        env:
75          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_api }}
77        with:
78          channel: '#api'
79          status: ${{ job.status }}
80          fields: job,commit,ref,eventName,author,took
81          author_name: Check packages
82